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 client cli command parameters #2012

Merged
merged 6 commits into from
Oct 17, 2024

Conversation

Alenar
Copy link
Collaborator

@Alenar Alenar commented Oct 16, 2024

Content

This PR change how parameters are passed to client-cli commands: Instead of providing a ConfigBuilder from the config crate a CommandContext new struct is passed so we can provide more than just configuration parameters to sub-commands.

This change is needed in order to remove slog_scope so we can share the main logger defined in the bin main.

Two others changes are included:

  • Introduce a SharedArgs struct so to define in one place arguments shared between all commands (only the --json option for now). It's flattened so this doesn't change the api.
  • Minimize use of the config crate by instead using a "source" system with the ConfigParameters. Using both crate to fetch the same thing (parameters) was quite confusing, this is changed so config is only used for its capacity of reading multiple files formats and to provide the initial hasmap of parameters.

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • No clippy warnings in the CI
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

@Alenar Alenar self-assigned this Oct 16, 2024
Copy link

github-actions bot commented Oct 16, 2024

Test Results

    4 files  ±0     55 suites  ±0   10m 26s ⏱️ -1s
1 370 tests +2  1 370 ✅ +2  0 💤 ±0  0 ❌ ±0 
1 584 runs  +8  1 584 ✅ +8  0 💤 ±0  0 ❌ ±0 

Results for commit 13e97a9. ± Comparison against base commit 3908e8a.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@dlachaume dlachaume left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

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

LGTM 👍

…ents

Only apply to `--json` but allow to easily add more if needed.
Similar but simpler than the one used by config, this will allow to
reduce confusion in our commands by only using the locally defined
ConfigParameters.
Using crate defined `ConfigParameters`.
Instead of passing only config parameters, this design allow to add
other shared dependencies such as a common logger.
Allowing subcommands to check it if needed.
* mithril-client-cli from `0.9.15` to `0.9.16`
@Alenar Alenar force-pushed the djo/refactor_client_cli_command_params branch from a643ee7 to 13e97a9 Compare October 17, 2024 10:14
@Alenar Alenar merged commit 7f3f4e5 into main Oct 17, 2024
48 checks passed
@Alenar Alenar deleted the djo/refactor_client_cli_command_params branch October 17, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants