Skip to content

Comments

refactor(cli): Unify CLI parameters and refactor CLI definition#347

Merged
mergify[bot] merged 14 commits intosigp:unstablefrom
dknopik:cli-refactor
Jul 16, 2025
Merged

refactor(cli): Unify CLI parameters and refactor CLI definition#347
mergify[bot] merged 14 commits intosigp:unstablefrom
dknopik:cli-refactor

Conversation

@dknopik
Copy link
Member

@dknopik dknopik commented May 27, 2025

Issue Addressed

Proposed Changes

  • Refactor logging crate
  • Introduce global config crate that contains shared options
  • Pass global config to subcommands to avoid duplicated logic about datadir and ssv network
  • Set default network to Hoodi
  • Adjust docs

Additional Info

This is not as scary to review as the lines changed seem to indicate, a lot comes from moving the logging crate around.

@dknopik dknopik added logging cli v0.1.0 First Testnet-only release labels May 27, 2025
@dknopik dknopik linked an issue May 27, 2025 that may be closed by this pull request
@dknopik dknopik removed the v0.1.0 First Testnet-only release label May 28, 2025
@Zacholme7
Copy link
Member

Passing thought, do we want to allow config via env vars?

@dknopik
Copy link
Member Author

dknopik commented May 30, 2025

@Zacholme7 good idea!

At least for the secondary commands it might be interesting to support e.g. ETH_RPC_URL to mimic Foundry's cast send

This comment was marked as outdated.

@dknopik
Copy link
Member Author

dknopik commented Jun 25, 2025

Any open questions/blockers on this?

Copy link
Member

@Zacholme7 Zacholme7 left a comment

Choose a reason for hiding this comment

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

small nits, lgtm otherwise

@dknopik dknopik added ready-for-review This PR is ready to be reviewed v0.2.0 Second testnet release labels Jun 27, 2025
@dknopik dknopik requested a review from diegomrsantos June 27, 2025 15:02
@dknopik dknopik added ready-for-review This PR is ready to be reviewed and removed do-not-merge waiting-on-author labels Jul 14, 2025
@mergify
Copy link

mergify bot commented Jul 14, 2025

Some required checks have failed. Could you please take a look @dknopik? 🙏

@mergify mergify bot added waiting-on-author and removed ready-for-review This PR is ready to be reviewed labels Jul 14, 2025
@dknopik
Copy link
Member Author

dknopik commented Jul 14, 2025

Simplified this for easier review and a smaller changeset. Logging refactoring will be reintroduced in an upcoming PR

@mergify mergify bot added ready-for-review This PR is ready to be reviewed and removed waiting-on-author labels Jul 14, 2025
@dknopik dknopik changed the title Unify CLI parameters and refactor CLI definition refactor(cli): Unify CLI parameters and refactor CLI definition Jul 16, 2025
@diegomrsantos diegomrsantos requested a review from Copilot July 16, 2025 11:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors the CLI by introducing a shared GlobalConfig crate, unifying common flags across subcommands, and cleaning up logging initialization.

  • Introduce common/global_config crate for shared CLI options (--data-dir, --network, etc.)
  • Refactor enable_logging to accept global flags and consolidate file logging layers
  • Update CLI documentation to show unified global options and adjust commands accordingly

Reviewed Changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
book/src/cli.md Consolidated global flags table and updated examples
anchor/src/main.rs Use GlobalConfig for data dir/network and refactored logging setup
anchor/logging/src/logging.rs Rewrote FileLoggingFlags, removed legacy config, updated init_file_logging
anchor/common/global_config/src/lib.rs Added GlobalFlags and TryFrom for GlobalConfig
anchor/common/global_config/Cargo.toml Declared new global_config crate in workspace
anchor/keysplit/src/cli.rs Removed per-command --network flag, rely on global flag
anchor/keygen/src/lib.rs Updated run_keygen to write to global data directory
Comments suppressed due to low confidence (4)

book/src/cli.md:25

  • The table still lists 'Mainnet' as a supported network, but GlobalFlags only allows holesky or hoodi. Update this row to reflect the actual supported networks.
| `--network <NETWORK>` | Network to use (Mainnet, Holesky, Hoodi) | `hoodi`               |

book/src/cli.md:250

  • [nitpick] The example places --network under the keysplit onchain subcommand, but --network is now a global flag. Consider moving it before the subcommand or noting that it can be used anywhere.
  --network mainnet

anchor/common/global_config/src/lib.rs:1

  • The new GlobalConfig parsing logic lacks unit tests. Consider adding tests for GlobalConfig::try_from to validate default data dir, network parsing, and error cases.
use std::{path::PathBuf, str::FromStr};

anchor/common/global_config/Cargo.toml:11

  • The strum dependency is declared but not used in global_config/src/lib.rs. You can remove it to keep dependencies minimal.
strum = { workspace = true }

@diegomrsantos
Copy link
Member

LGTM, only small nits. Please take a look at the last copilot comments.

Copy link
Member

@diegomrsantos diegomrsantos left a comment

Choose a reason for hiding this comment

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

Thanks!

@dknopik dknopik added ready-for-merge and removed ready-for-review This PR is ready to be reviewed labels Jul 16, 2025
mergify bot added a commit that referenced this pull request Jul 16, 2025
@mergify mergify bot merged commit 3781050 into sigp:unstable Jul 16, 2025
17 checks passed
@dknopik dknopik deleted the cli-refactor branch July 18, 2025 08:56
diegomrsantos pushed a commit to diegomrsantos/anchor that referenced this pull request Sep 17, 2025
…#347)

- sigp#266


  - Refactor logging crate
- Introduce global config crate that contains shared options
- Pass global config to subcommands to avoid duplicated logic about datadir and ssv network
- Set default network to Hoodi
- Adjust docs
jking-aus pushed a commit to jking-aus/anchor that referenced this pull request Oct 8, 2025
…#347)

- sigp#266


  - Refactor logging crate
- Introduce global config crate that contains shared options
- Pass global config to subcommands to avoid duplicated logic about datadir and ssv network
- Set default network to Hoodi
- Adjust docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unify CLI parameters

3 participants