Joystream / Joystream/joystream

CLI: How to ensure it is scriptable

Open
#1,571 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CLI
Dominant language
Rust
Stars
1.4k
Forks
116
PR merge metrics
No merged PRs in 30d

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:

  1. 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.
  2. 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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the media:MyVideos and content-directory:entity command entry points described in the issue, and trace how they gather input and render output. Define the scope for non-interactive stdin or arguments and machine-readable JSON, then verify the example pipeline works end to end; the issue names no files or tests.

Written by the indexing model from the issue text.

Assessment

Domain
cli, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.