refactor(cli): Unify CLI parameters and refactor CLI definition#347
refactor(cli): Unify CLI parameters and refactor CLI definition#347mergify[bot] merged 14 commits intosigp:unstablefrom
Conversation
|
Passing thought, do we want to allow config via env vars? |
|
@Zacholme7 good idea! At least for the secondary commands it might be interesting to support e.g. |
|
Any open questions/blockers on this? |
|
Some required checks have failed. Could you please take a look @dknopik? 🙏 |
|
Simplified this for easier review and a smaller changeset. Logging refactoring will be reintroduced in an upcoming PR |
There was a problem hiding this comment.
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_configcrate for shared CLI options (--data-dir,--network, etc.) - Refactor
enable_loggingto 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
GlobalFlagsonly allowsholeskyorhoodi. 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
--networkunder thekeysplit onchainsubcommand, but--networkis 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
GlobalConfigparsing logic lacks unit tests. Consider adding tests forGlobalConfig::try_fromto validate default data dir, network parsing, and error cases.
use std::{path::PathBuf, str::FromStr};
anchor/common/global_config/Cargo.toml:11
- The
strumdependency is declared but not used inglobal_config/src/lib.rs. You can remove it to keep dependencies minimal.
strum = { workspace = true }
|
LGTM, only small nits. Please take a look at the last copilot comments. |
Issue Addressed
Proposed Changes
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.