balena-io / balena-cli

The official balena CLI tool.
Apache License 2.0
452 stars 139 forks source link

Implement scriptable (non-interactive) mode #1089

Open pdcastro opened 5 years ago

pdcastro commented 5 years ago

Placeholder feature issue -- requires further discussion

This is a generalisation of several specific feature requests from CLI end users:

89, #462, #695, #789, #837, #1001, #1043, #1697 and more

Implement a consistent flag through all CLI commands to enable "scriptable/CI/robot mode", as opposed to "human/interactive mode":

Interactive mode assumes a human reading the output:

Scriptable/CI/robot mode produces parseable output like JSON / CSV / TSV:

CLI can automatically detect whether stdin is a tty terminal (@CameronDiver's proposal)

Front logo Front conversations

imrehg commented 5 years ago

This would be very useful to have, as otherwise e.g. balena ssh in scripting mode can connect to the completely wrong device, if used in a script and given an invalid UUID or a UUID that the user cannot connect to. In that case, the menu is popped up, and in interactive mode, the first device is connected to.

Thus for SSH at least could work as well:

pdcastro commented 4 years ago

Finding related to this issue: @CameronDiver pointed out that oclif has a cli-ux.table function that adds several command-line options for data formatting (csv, json, yaml) that could be handy to have in a scriptable / parseable mode:

https://oclif.io/docs/table

OPTIONS
  -x, --extended          show extra columns
  --columns=columns       only show provided columns (comma-separated)
  --csv                   output is csv format [alias: --output=csv]
  --filter=filter         filter property by partial string matching, ex: name=foo
  --no-header             hide table header from output
  --no-truncate           do not truncate output to fit screen
  --output=csv|json|yaml  output in a more machine friendly format
  --sort=sort             property to sort by (prepend '-' for descending)
jellyfish-bot commented 4 years ago

[ntzovanis] This issue has attached support thread https://jel.ly.fish/1418fb56-c0b7-4861-8ab1-75584e15f367

jellyfish-bot commented 4 years ago

[rahul-thakoor] This issue has attached support thread https://jel.ly.fish/a675f6e4-6dcf-4de9-a566-a6e52da23104

jellyfish-bot commented 3 years ago

[pdcastro] This issue has attached support thread https://jel.ly.fish/1e5ecda0-b7d7-4f7e-9e8e-935861e479b9