-
Notifications
You must be signed in to change notification settings - Fork 117
Description
The joystream/cli has good support for interactive style which is very helpful and user friendly for some of the commands that require a lot of input/arguments from the user, prompting user to enter values for fields, checking validity, offering list of choices etc. The output in many cases is presented in a human readable form, sometimes single liner and in many cases multiple tables with various number of columns.
In order for the cli to be script-able there are two key requirements:
- It should be possible to not require any interactivity, and therefore we must ensure that all commands can be executed by providing all inputs through commandline arguments or by reading a file from stdin. I believe this is already the case for many commands.
- The output should be optionally formatted in a simple to parse format, so the output can easily be piped to other commands and even the joystream/cli itself. Given the rich output many of the command output, JSON seems like a viable choice.
eg. I want to query MyVideos and get details of the curation status of one particular video. Currently this involves:
cli media:MyVideos
looking in list of videos for entity id of the video of interest
cli content-directory:entity $VIDEO_ID
looking in the properties table for the entity id that represents the curation status:
cli content-directory:entity $CURATION_STATUS_ID
If the MyVideos command outputted json like
[{
"id": 5,
"channel": 7
"title": "MyVideo 1"
},
{
"id": 6,
"channel": 7
"title": "MyVideo 2"
}]
and the content-directory:entity command could read a line from stdin to get the entity id, and output json like:
{
"id": 5
"properties": [
a,
b,
c, // curation status entity id
]
}
we could write a command like:
cli media:MyVideos | jq '.[0] | .id' | cli content-directory:entity | jq '.properties | '.[2]' | cli:entity
┆Issue is synchronized with this Asana task by Unito