nathants/libaws

[+] Feature Request: -j | --json Output

Closed this issue · 1 comments

Hi, thanks for this awesome cli/lib.
It would be nice if some of the cli (that produce output) had a option to output in json.
-p,--preview exsists, but a native -j,--json would be very handy as I currently have to use bash magic to parse the output.

I implemented a somewhat basic -j | --json output for ec2-ls at : https://github.com/Azathothas/libaws-cli/blob/master/cmd/ec2/ls.go

[
  {
    "name": "test",
    "type": "t2.micro",
    "state": "running",
    "id": "i-02f6dc5jk89cbdf23",
    "image": "ami-0cf2b4e026cdb7210",
    "kind": "ondemand",
    "security-group": "launch-wizard-2",
    "tags": ""
  },
  {
    "name": "ivn_ec2_arm_t4g",
    "type": "t4g.small",
    "state": "running",
    "id": "i-033f1321fff312130",
    "image": "ami-07564a09643c45542",
    "kind": "ondemand",
    "security-group": "launch-wizard-1",
    "tags": ""
  }
]

your cli is very cool!

typically i am either awking at the cmdline, or using libaws as a go sdk.

some things output json, but not all. might be nice to standardize output at some point, but not sure it's worth the effort. there are 153 cli entrypoints.

the cli is just a gateway to using the lib as a go sdk. for more serious use, always use the sdk directly.

infra-ls outputs yaml in a very standardized way. you can use it to list instances and everything else in your account. pipe it to yq.