Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Reorganize global CLI flags #2615

Merged
merged 7 commits into from
May 14, 2024

Conversation

nasdf
Copy link
Member

@nasdf nasdf commented May 13, 2024

Relevant issue(s)

Resolves #2614
Resolves #2582

Description

This PR moves the global CLI flags that only apply to the start command. It also fixes the log color config issue above.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

make test

Specify the platform(s) on which this was tested:

  • MacOS

@nasdf nasdf added refactor This issue specific to or requires *notable* refactoring of existing codebases and components area/cli Related to the CLI binary labels May 13, 2024
@nasdf nasdf added this to the DefraDB v0.12 milestone May 13, 2024
@nasdf nasdf self-assigned this May 13, 2024
@nasdf nasdf requested a review from a team May 13, 2024 23:57
cli/config.go Outdated
"log-stacktrace": "log.stacktrace",
"log-source": "log.source",
"log-overrides": "log.overrides",
"log-no-color": "log.nocolor",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Would be nice to have a consistent usage of no and disable terminology and the no prefix to disable a feature.

For example: To disable key ring and p2p users use: no-keyring and no-p2p respectively, i.e. leading no prefix

But for disabling log, it is log-no-color rather than no-log-color.

Now for config keys we use: keyring.disabled net.p2pdisabled (the disabled term)

But for log we have log.nocolor instead of log.colordisabled

IMO would be nice to have at least user facing flags to be predictable / consistent in terminology.

cli/config.go Outdated
@@ -138,6 +139,7 @@ func loadConfig(rootdir string, flags *pflag.FlagSet) (*viper.Viper, error) {
Output: cfg.GetString("log.output"),
EnableStackTrace: cfg.GetBool("log.stacktrace"),
EnableSource: cfg.GetBool("log.source"),
DisableColor: cfg.GetBool("log.nocolor"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😁

Copy link
Contributor

@AndrewSisley AndrewSisley May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: The // set default logging config appears incorrect though - this is not setting the default, but instead takes from the CLI params? Suggest either changing the comment or removing it.

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Keenan :) One suggestion from me before merge, and I agree with Shahzad's no vs disable suggestion too

@nasdf nasdf merged commit 530f21e into sourcenetwork:develop May 14, 2024
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Related to the CLI binary refactor This issue specific to or requires *notable* refactoring of existing codebases and components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reorganize global CLI flags defradb start --log-no-color does not disable coloured logging
3 participants