2019-05-24 10:25:55 +02:00
|
|
|
use crate::common::*;
|
|
|
|
|
|
|
|
#[derive(StructOpt)]
|
2020-03-07 07:50:04 +01:00
|
|
|
pub(crate) struct Options {
|
2020-01-24 23:17:31 +01:00
|
|
|
#[structopt(
|
|
|
|
long = "unstable",
|
|
|
|
short = "u",
|
|
|
|
help = "Enable unstable features.",
|
2020-03-06 07:51:00 +01:00
|
|
|
long_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 23:17:31 +01:00
|
|
|
)]
|
2019-05-24 10:25:55 +02:00
|
|
|
unstable: bool,
|
2020-01-16 08:37:12 +01:00
|
|
|
#[structopt(
|
|
|
|
long = "color",
|
|
|
|
default_value = use_color::AUTO,
|
|
|
|
set = ArgSettings::CaseInsensitive,
|
|
|
|
possible_values = use_color::VALUES,
|
2020-01-24 23:17:31 +01:00
|
|
|
help = "Print colorful output.",
|
2020-03-06 07:51:00 +01:00
|
|
|
long_help = "Print colorful output. 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 with a \
|
|
|
|
value of `dumb`.",
|
2020-01-16 08:37:12 +01:00
|
|
|
)]
|
|
|
|
pub(crate) use_color: UseColor,
|
2020-02-05 06:29:53 +01:00
|
|
|
}
|
|
|
|
|
2020-03-07 07:50:04 +01: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-05 06:29:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|