cli icon indicating copy to clipboard operation
cli copied to clipboard

Implemented global --quiet (-q) flag

Open kanha-gupta opened this issue 1 year ago • 13 comments

Fixes https://github.com/civo/cli/issues/497

The PR is divided in two commits -

  1. centralize the logging. Added a logger.go file in utility package which is being called throughout the codebase, replacing fmt.println() and fmt.printf()
  2. Actual implementation on top of the first commit.

Working demo ->

Screenshot from 2025-02-18 03-33-48 Screenshot from 2025-02-18 03-34-03 Screenshot from 2025-02-18 03-34-20 Screenshot from 2025-02-18 03-46-39

kanha-gupta avatar Feb 17 '25 22:02 kanha-gupta

Hi @fernando-villalba @uzaxirr please review this :)

kanha-gupta avatar Feb 17 '25 22:02 kanha-gupta

Hi @kanha-gupta! Thanks for the contribution and sorry for the delay! We will review this shortly 😄

Unfortunately there are some conflicts with the master branch: you can go ahead and resolve them if you're still interested in contributing, otherwise we can take it from here! 👍

Thanks again!

giornetta avatar May 06 '25 07:05 giornetta

Hi @giornetta can you take a look at the approach I have taken ? if you like the approach, I'll go ahead and resolve conflicts. Thanks

kanha-gupta avatar May 09 '25 19:05 kanha-gupta

@kanha-gupta I personally like the approach. @fulviodenza @uzaxirr what's your take?

giornetta avatar May 12 '25 07:05 giornetta

This approach seems fine. but my only concern is too many files being modified in this PR. Can you divide them?

uzaxirr avatar May 12 '25 08:05 uzaxirr

this MR changes the Printing of the output nesting the --quiet logic, so I cannot imagine a way to divide these files, correct me if I'm wrong @uzaxirr

alessandroargentieri avatar May 12 '25 08:05 alessandroargentieri

@alessandroargentieri We can divide this in Multiple PRs, first just a PR to introduce logger in utility and changeing just 2-3 files. and then PRs to change them in resources, ideally i would say one PR for 2 resources.

uzaxirr avatar May 12 '25 08:05 uzaxirr

Hi @giornetta @alessandroargentieri @uzaxirr Thanks for the review ! I can surely divide this PR into smaller ones. just let me know if I should open all the PRs at the same time or one by one. I'll proceed upon your confirmation. Thanks once again !

kanha-gupta avatar May 12 '25 18:05 kanha-gupta

Not necessary. Me and @uzaxirr clarified on on that point and agreed on merging if you solve the conflicts. Indeed, since it's a single feature, dividing into more than one PR means fragmenting the single feature which is something potentially introducing some refuses.

alessandroargentieri avatar May 12 '25 18:05 alessandroargentieri

Not necessary. Me and @uzaxirr clarified on on that point and agreed on merging if you solve the conflicts. Indeed, since it's a single feature, dividing into more than one PR means fragmenting the single feature which is something potentially introducing some refuses.

@alessandroargentieri Thanks for the info. I have resolved merge conflicts. you can merge now :)

kanha-gupta avatar May 12 '25 19:05 kanha-gupta

I would make sure that every fmt.Printf or other printing functions are replaced with this PR before merging it.

I suppose many new features have been added since this PR was opened, so some new functions may not use this new approach

giornetta avatar May 12 '25 19:05 giornetta

I wish a rebase has been done and a search all functionality has been used. Isn't it @kanha-gupta ?

alessandroargentieri avatar May 12 '25 20:05 alessandroargentieri

I would make sure that every fmt.Printf or other printing functions are replaced with this PR before merging it.

I suppose many new features have been added since this PR was opened, so some new functions may not use this new approach

I would love that too ! unfortunately, I had to leave few modules due to "import cycle" issue during development. These are the following :

  1. config/config.go
  2. common/common.go
  3. cmd/loadbalancer/loadbalancer_remove.go.disabled - left it because it's already disabled, might be useful for future reference ?

Except from these, fmt.Print is refactored in every file. Figured out that I'll have to create a new module just for a logger file so skipped these two. I would appreciate a better approach from your side :)

kanha-gupta avatar May 12 '25 21:05 kanha-gupta