prasmussen / chrome-cli

Control Google Chrome from the command line
MIT License
2.61k stars 89 forks source link

feature: every command should support `--json` for json output, for reliable scripting #55

Closed timotheecour closed 2 years ago

timotheecour commented 4 years ago

eg:

this makes for reliable scripting (analog to git's porcelain vs plumbing mode) that won't break in case output adds new fields etc

kellyjonbrazil commented 2 years ago

Any chance a JSON output option could be considered? I received a request to add a crome-cli parser to jc to convert the output to JSON, but it would be nice if this was done natively.

prasmussen commented 2 years ago

I just released 1.8.0 (available via brew) which has support for json output. It can be enabled with the OUTPUT_FORMAT env variable (this was the easiest way to implement it – I really should port chrome-cli to Swift one day...).

Usage example:

OUTPUT_FORMAT="json" brave-cli info
{
  "id" : 2785,
  "loading" : false,
  "title" : "feature: every command should support `--json` for json output, for reliable scripting · Issue #55 · prasmussen/chrome-cli",
  "url" : "https://github.com/prasmussen/chrome-cli/issues/55",
  "windowId" : 26
}