`civo <resourcetype> ls` should show output even if empty
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.
Hi @kaihoffman @andyjeffries @DMajrekar I would love to work on this. Could you assign this issue to me?
@kitarp29 did you have a chance to look at this? Would love to be able to close this off!
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?
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.
If the fix I applied here works for you, I will replicate for the other commands as well :)
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 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?
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 :)
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.