apache / apache/openwhisk-cli

CLI Feature Request: @file support for action invoke

Open
#145 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
109
Forks
98
PR merge metrics
No merged PRs in 30d

Description

@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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.