cli icon indicating copy to clipboard operation
cli copied to clipboard

`civo <resourcetype> ls` should show output even if empty

Open kaihoffman opened this issue 3 years ago • 9 comments

Currently, if you have selected a region where you have no resources, you may get an empty response to a listing of resources:

$ civo instance ls
$

This is confusing especially if you do not know you have changed regions.

It might be helpful to have a note about which region you're in when listing a region with an empty output. Compare to output from a listing with instances running in it, which shows the region:

$ civo instance ls
+--------------------------------------+--------------+--------+----------+-----------+------+----------+---------------+-------------+--------+
| ID                                   | Hostname     | Region | Size     | Cpu Cores | Ram  | SSD disk | Public IP     | Private IP  | Status |
+--------------------------------------+--------------+--------+----------+-----------+------+----------+---------------+-------------+--------+
| aa068118-40ac-4fc8-b5ea-fb5202a2061a |   hostname   | LON1   | g3.small |         1 | 2048 |       25 | 12.34.56.78 | 192.168.1.2 | ACTIVE |
+--------------------------------------+--------------+--------+----------+-----------+------+----------+---------------+-------------+--------+

I suggest having something like

$ civo instance ls
Current region is NYC1. No instances found.

kaihoffman avatar Jun 21 '22 15:06 kaihoffman

Hi @kaihoffman @andyjeffries @DMajrekar I would love to work on this. Could you assign this issue to me?

kitarp29 avatar Jun 27 '22 19:06 kitarp29

@kitarp29 did you have a chance to look at this? Would love to be able to close this off!

kaihoffman avatar Aug 18 '22 20:08 kaihoffman

Hi @kaihoffman Sorry for the delay got stuck with University exams. Could you direct me to right file or location I will find the output to the commands?

kitarp29 avatar Aug 19 '22 03:08 kitarp29

It would need to determine whether the resourcetype is found, and determine the output accordingly @kitarp29 .

For example, the instance ls command output is at https://github.com/civo/cli/blob/master/cmd/instance/instance_list.go but it would need to apply equally to other resource types that can be listed.

kaihoffman avatar Aug 19 '22 16:08 kaihoffman

If the fix I applied here works for you, I will replicate for the other commands as well :)

kitarp29 avatar Aug 20 '22 16:08 kitarp29

Hey @kaihoffman Could have a look into this It's not a big breaking change, if you could conform we can get this done sooner.

  • https://github.com/civo/cli/pull/246#issuecomment-1221400058

kitarp29 avatar Aug 22 '22 17:08 kitarp29

@kitarp29 I'm not the best placed to judge a golang PR in our team, I'm afraid - I'll leave it to @alejandrojnm or @RealHarshThakur to have a look?

kaihoffman avatar Aug 22 '22 19:08 kaihoffman

I mean I'm very new to the codebase myself, so can't say I have the best approach. But surely an approach that will work :)

kitarp29 avatar Aug 22 '22 19:08 kitarp29

It's less about the particular codebase and more about best practices @kitarp29 - I'm not qualified to judge what is efficient and idiomatic golang.

kaihoffman avatar Aug 22 '22 21:08 kaihoffman