civo / cli

Our Command Line Interface (CLI) for interacting with your Civo resources
Apache License 2.0
173 stars 86 forks source link

Wrong region displayed in message when no resources found #436

Closed fernando-villalba closed 2 months ago

fernando-villalba commented 3 months ago

Issue

When you run the following command:

 civo instance --region nyc1 ls

And no resources are found, the wrong region will display in the message, here are examples when default region set to LON1

image

This is because when issue 404 was implemented the region output is set to show the default as shown here:

image

Acceptance criteria

Praveen005 commented 2 months ago

Hi Team,

I just looked into this issue and to solve it,

we can write a check in FinishAndPrintOutput() like below, as using civo instance --region nyc1 ls command will set common.RegionSet to nyc1

       if len(ow.Values) == 0 {
                var region string
                if common.RegionSet != ""{
                    region = common.RegionSet
                }else{
            region = config.Current.Meta.DefaultRegion
        }
        fmt.Fprintf(os.Stderr, "No resources found in region %s. For a list of regions use the command 'civo region ls'\n", region)
    }

I kindly request your review.

Regards,

Praveen

haardikdharma10 commented 2 months ago

That looks good to me @Praveen005. Do you want to open a PR with that change along with a screenshot that the command works and i'd be happy to approve and merge.

Praveen005 commented 2 months ago

Hey, @haardikdharma10 ,

when I run the command it doesn't go through, since I don't have an active civo account. Can you kindly test the changes on your end?

Screenshot 2024-07-11 125143

Thank you.

haardikdharma10 commented 2 months ago

@Praveen005 - I tested the change and it works as expected. I have merged the PR and closing this issue. The change should be visible when we release our next version.