-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adopt clap-ext #51
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| //! Smoke tests verifying that clap-ext's Verbosity and ConfigArg work in this CLI. | ||
|
|
||
| use clap::Parser; | ||
| use clap_ext::prelude::*; | ||
|
|
||
| #[test] | ||
| fn clap_ext_verbosity_parses_quiet_flag() { | ||
| #[derive(Parser)] | ||
| struct Probe { | ||
| #[command(flatten)] | ||
| verbosity: Verbosity, | ||
| } | ||
| let p = Probe::try_parse_from(["probe", "--quiet"]).expect("parse"); | ||
| let filter = p.verbosity.to_filter(); | ||
| assert_eq!(format!("{:?}", filter), "ERROR"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn clap_ext_verbosity_parses_double_v() { | ||
| #[derive(Parser)] | ||
| struct Probe { | ||
| #[command(flatten)] | ||
| verbosity: Verbosity, | ||
| } | ||
| let p = Probe::try_parse_from(["probe", "-vv"]).expect("parse"); | ||
| let filter = p.verbosity.to_filter(); | ||
| assert_eq!(format!("{:?}", filter), "TRACE"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn clap_ext_config_arg_default_is_none() { | ||
| #[derive(Parser)] | ||
| struct Probe { | ||
| #[command(flatten)] | ||
| config: ConfigArg, | ||
| } | ||
| let p = Probe::try_parse_from(["probe"]).expect("parse"); | ||
| assert!(p.config.path().is_none()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Config default test ignores envMedium Severity
Reviewed by Cursor Bugbot for commit c6b9592. Configure here. |
||
| } | ||
|
|
||
| #[test] | ||
| fn clap_ext_config_arg_parses_short_flag() { | ||
| #[derive(Parser)] | ||
| struct Probe { | ||
| #[command(flatten)] | ||
| config: ConfigArg, | ||
| } | ||
| let p = Probe::try_parse_from(["probe", "-c", "/tmp/cfg.toml"]).expect("parse"); | ||
| assert_eq!(p.config.path().unwrap().to_str().unwrap(), "/tmp/cfg.toml"); | ||
| } | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: This assertion is environment-dependent:
ConfigArgalso reads fromPHENOTYPE_CONFIG, so on machines/CI where that env var is set, parsing with no CLI args will produceSome(path)and this test will fail nondeterministically. Clear or scopePHENOTYPE_CONFIGfor this test before parsing so the default behavior is tested in isolation. [logic error]Severity Level: Major⚠️
Steps of Reproduction ✅
Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖