2019-05-24 01:25:55 -07:00
|
|
|
use crate::common::*;
|
|
|
|
|
|
|
|
#[derive(StructOpt)]
|
2020-03-06 22:50:04 -08:00
|
|
|
pub(crate) struct Options {
|
2020-01-24 14:17:31 -08:00
|
|
|
#[structopt(
|
|
|
|
long = "unstable",
|
|
|
|
short = "u",
|
2020-03-06 23:25:15 -08:00
|
|
|
help = "Enable unstable features. To avoid premature stabilization and excessive version \
|
|
|
|
churn, unstable features are unavailable unless this flag is set. Unstable features \
|
|
|
|
are not bound by semantic versioning stability guarantees, and may be changed or \
|
|
|
|
removed at any time."
|
2020-01-24 14:17:31 -08:00
|
|
|
)]
|
2019-05-24 01:25:55 -07:00
|
|
|
unstable: bool,
|
2020-01-15 23:37:12 -08:00
|
|
|
#[structopt(
|
|
|
|
long = "color",
|
2020-03-07 00:52:44 -08:00
|
|
|
value_name = "WHEN",
|
2020-03-27 18:41:35 -07:00
|
|
|
default_value = UseColor::Auto.into(),
|
|
|
|
possible_values = UseColor::VARIANTS,
|
2020-03-07 00:52:44 -08:00
|
|
|
help = "Print colorful output according to `WHEN`. When `auto`, the default, colored output \
|
|
|
|
is only enabled if imdl detects that it is connected to a terminal, the `NO_COLOR` \
|
|
|
|
environment variable is not set, and the `TERM` environment variable is not set to \
|
|
|
|
`dumb`.",
|
2020-01-15 23:37:12 -08:00
|
|
|
)]
|
|
|
|
pub(crate) use_color: UseColor,
|
2020-02-04 21:29:53 -08:00
|
|
|
}
|
|
|
|
|
2020-03-06 22:50:04 -08:00
|
|
|
impl Options {
|
|
|
|
pub(crate) fn require_unstable(&self, feature: &'static str) -> Result<(), Error> {
|
|
|
|
if self.unstable {
|
|
|
|
Ok(())
|
|
|
|
} else {
|
|
|
|
Err(Error::Unstable { feature })
|
2020-02-04 21:29:53 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|