CLI Feature Request: @file support for action invoke
- Lingua principale
- Go
- Stelle
- 109
- Fork
- 98
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
@starpit commented on [Tue Dec 20 2016](https://github.com/apache/incubator-openwhisk/issues/1671)
It would be handy to have `@file` support, analogous to that in curl. For example:
```
wsk action invoke myAction -p input @filename
```
In which the CLI would JSON.stringify the contents of the file. In addition, it would be nice if the command line could specify the encoding of the file. For example, if the file is encoded UTF-16, the CLI needs to know this, so that it can stringify the file properly. For now, perhaps it could iconv the file to UTF-8 and stringify it. Suggestion for UTF-16:
```
wsk action invoke myAction -p input @utf16:filename
```
---
@dubeejw commented on [Tue Dec 20 2016](https://github.com/apache/incubator-openwhisk/issues/1671#issuecomment-268271606)
JSON file input support exists in the CLI currently. The encoding support does not, however.
` -P, --param-file FILE, FILE containing parameter values in JSON format`
---
@starpit commented on [Tue Dec 20 2016](https://github.com/apache/incubator-openwhisk/issues/1671#issuecomment-268275620)
hi @dubeejw thanks for the response. we need something more than that. think of the case of an XML document as input to an action invocation. the XML document needs to be stringified (after all, it has double quotes!) before it can be passed as input to an openwhisk action.
yes, i could script this externally, but i think it'd be nice to just have this support directly in the CLI.
it gets even more messy when considering non-ascii encodings.
---
@starpit commented on [Tue Dec 20 2016](https://github.com/apache/incubator-openwhisk/issues/1671#issuecomment-268278573)
here is how i ended up invoking my action with a utf-16 xml document as input:
```
% echo "{\"xmlInput\": "`iconv --unicode-subst=formatstring -f utf-16 -t us-ascii < sample.xml | node conv.js`"}" > in.json
% wsk action invoke cogdigity/export2json --param-file in.json
```
notice the use of: 1) `iconv`, and 2) a nodejs program to help with stringifying (i could've used sed or awk here, i just gave up trying to figure out the escaping of escaping of escaping... nonsense)
---
@rabbah commented on [Tue Dec 20 2016](https://github.com/apache/incubator-openwhisk/issues/1671#issuecomment-268281378)
the param file also requires one to modify the file to nest the payload into a json property - i does not quite satisfy the feature requested here even if you set aside the encoding.
---
@jthomas commented on [Thu Dec 22 2016](https://github.com/apache/incubator-openwhisk/issues/1671#issuecomment-268760155)
It would be nice to also be able to pipe content as input.
```
cat file.json | wsk action invoke my_action
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dalla gestione dei parametri del comando action invoke e dall’opzione --param-file esistente. Confronta gli esempi richiesti per @file e la codifica con il comportamento attuale dei parametri JSON; il lavoro sarà completo quando i contenuti dei file potranno essere convertiti in stringhe e forniti direttamente, inclusa la codifica specificata, e il comportamento da riga di comando sarà coperto dai test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- go
- Ambito
- cli, tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100