-
Notifications
You must be signed in to change notification settings - Fork 379
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
Support cargo term variables. #921
Conversation
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.
lgtm!
the clap Option<String>
should be converted to ColorChoice
though, with default auto
Should I change everything to an enumerated values? I had it a list of options with a default earlier, but removed it because of envvars, but I can restore it. |
That's the same I believe, just using the derive API. |
It creates really bad help messages when we change those, so I've just made sure the error messages for invalid colors are nicer. Using Clap EnumParser Using Custom Validation I even tried the following, but it doesn't do enough: /// Coloring: auto, always, never
#[clap(
long,
arg_enum,
env = "CARGO_TERM_COLOR",
hide_possible_values = true,
hide_env_values = true,
hide_default_value = true,
)]
pub color: ColorChoice, I've made sure the output is similar to clap however, identical even on small terms. Generic Clap Cross Error |
Use the `CARGO_TERM_VERBOSE`, `CARGO_TERM_QUIET`, and `CARGO_TERM_COLOR` environment variables for cross terminal output. This enables us to detect term settings via environment variables, which are overridden by command-line flags, which is our own behavior. Cargo has CLI flags override environment variables, and verbose and quiet cannot be set for the same level. So if `CARGO_TERM_VERBOSE=true` and `--quiet` are used, then we use the quiet setting, but if `--verbose` and `--quiet` are used, then we print a fatal error message.
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.
bors r+
Build succeeded: |
Use the
CARGO_TERM_VERBOSE
,CARGO_TERM_QUIET
, andCARGO_TERM_COLOR
environment variables for cross terminal output. This enables us to detect term settings via environment variables, which are overridden by command-line flags, which is our own behavior.Cargo has CLI flags override environment variables, and verbose and quiet cannot be set for the same level. So if
CARGO_TERM_VERBOSE=true
and--quiet
are used, then we use the quiet setting, but if--verbose
and--quiet
are used, then we print a fatal error message.Closes #919.