-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(level): add off, debug, and trace options for default Level #95
Conversation
344b516
to
4a0a458
Compare
|
||
/// Default to [`None`] | ||
#[derive(Copy, Clone, Debug, Default)] | ||
pub struct OffLevel; |
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.
In #10, we talked about how to handle --quiet
but neither the code nor the description addresses this.
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.
I added the suggestion of hide
value_parser that is assigned to a function that conditionally returns UnknownArgumentValueParser when L::default().is_none()
For this one I looked around the docs, and am not very familiar with clap value parsers, or how to use them conditionally in conjunction with actions. I can keep investigating this, I just wanted to address the other items first, and maybe get some guidance here.
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.
This would be something like:
fn default_value_parser::<L: LogLevel>() -> clap::builder::ValueParser {
if L::default().is_some() {
clap::builder::UnknownArgumentValueParser::suggest("'--quiet' is the default").into()
} else {
clap::builder::value_parser!(u8).into()
}
}
...
#[arg(value_parser = default_value_parser::<L>())]
Still not entirely sure its the right call to make but starting with an error is the safer choice as we can stop erroring without a breaking change but to start erroring is a breaking change.
Hmm, maybe instead we should make LogLevel
in charge of this. If we provide inherent impls, then its generally recognized as not a major breaking change.
This would instead look like
pub trait LogLevel {
// ...
fn hide_quiet() -> bool {
Self::default().is_none();
}
fn hide_verbose() -> bool {
false
}
fn quiet_value_parser() -> bool {
if L::default().is_some() {
clap::builder::UnknownArgumentValueParser::suggest("'--quiet' is the default").into()
} else {
clap::builder::value_parser!(u8).into()
}
}
fn verbose_value_parser() -> bool {
clap::builder::value_parser!(u8).into()
}
}
Non-blocker: in the future
|
4a0a458
to
593a711
Compare
Apologies, I am new to making contributions to projects. I will note this for the future 👍🏼
Sorry about that, I am getting bad commit habits from work. I have separated my commits in this PR. I have addressed all but one of the concerns, I am planning on continuing to look into how to conditionally disable a flag with the suggested approach. |
It is definitely a different world to get used to on-board to faceless projects like this. Best way is to try and see what works. Glad you are here trying! |
This was completed in #124 and can be closed now. |
add example for chaning the default, and mention in the docs
See #10 for some prior discussion