cli icon indicating copy to clipboard operation
cli copied to clipboard

CLI feature request: Allow custom output on `ls` commands.

Open kaihoffman opened this issue 2 years ago • 7 comments

Another one from @andyjeffries:

Would be really nice if the ls commands allowed filtering of the results, so you can use the output in scripts easier. I’d like this just to output the ID of the matching firewall, not all firewalls:

$ civo firewall ls WebTest -o custom -f id
8ea53815-3807-4726-88c8-7ce044c8238a
3a56a51e-634d-4d2a-adb6-7c54ac4e6d02

You can already filter to custom fields on the show command but might be useful on ls too?

kaihoffman avatar Jul 14 '23 15:07 kaihoffman

@kaihoffman I'm guessing the show being talked about here is referring to civo instance show ?

abs007 avatar Dec 01 '24 07:12 abs007

@abs007 not just instance, but every command that has a show details subcommand.

kaihoffman avatar Dec 02 '24 14:12 kaihoffman

So, I see the civo firewall ls cmd already has the following fields: id, name, network... for getting custom data for civo firewall, similar to what the show subcmd does. So, what else would be required for ls in this scenario?

abs007 avatar Dec 02 '24 17:12 abs007

So, I see the civo firewall ls cmd already has the following fields: id, name, network... for getting custom data for civo firewall, similar to what the show subcmd does. So, what else would be required for ls in this scenario?

Being able to filter based on a switch, to only output the requested field rather than all fields.

kaihoffman avatar Dec 02 '24 20:12 kaihoffman

Sorry to be repeating the same question again but isnt that already implemented for ls? I see the above mentioned fields and this example as well: civo firewall ls -o custom -f "ID: Name" when I run civo firewall ls -h

Can @alejandrojnm or @uzaxirr confirm?

abs007 avatar Dec 03 '24 06:12 abs007

You're right, @abs007 . It does have the ability to output custom fields in ls subcommands. But the syntax is different:

$ civo firewall ls -o custom -f id
80e453e8-edfa-4b67-8135-a3d5095f16bc
f6beace9-8196-42f3-9c23-aae9ca0d087c
...

However, the help text command does not output correctly:

 civo firewall ls -o custom -f "ID: Name"
ID: Name
ID: Name
...

In fact, you can chain custom output of fields, but you have to use the correct syntax (lower case id, lower case network etc) it seems:

$ civo firewall ls -o custom -f "id, network, name"
f6beace9-8196-42f3-9c23-aae9ca0d087c, Default, foobar
...

I guess we would need the help text corrected, and the CLI to parse the downcasing of output columns if not provided in lowercase.

kaihoffman avatar Dec 16 '24 20:12 kaihoffman

Going by Andy's req and what you mentioned above, what's needed is:

  1. Output for the ID_Name firewall only, when running civo firewall ls WebTest -o custom -f ID_Name
  2. Correcting the Example help statment for civo firewall ls
  3. Support for parsing fields accidentally passed as UpperCase

Please correct me if Im wrong

abs007 avatar Dec 29 '24 12:12 abs007