intermodal/src/opt.rs

54 lines
1.7 KiB
Rust
Raw Normal View History

2019-05-24 10:25:55 +02:00
use crate::common::*;
mod torrent;
#[derive(StructOpt)]
pub(crate) enum Subcommand {
Torrent(torrent::Torrent),
}
impl Subcommand {
pub(crate) fn run(self, env: &mut Env, unstable: bool) -> Result<(), Error> {
match self {
Self::Torrent(torrent) => torrent.run(env, unstable),
}
}
}
2019-05-24 10:25:55 +02:00
#[derive(StructOpt)]
#[structopt(
about(consts::ABOUT),
version(consts::VERSION),
author(consts::AUTHOR),
help_message(consts::HELP_MESSAGE),
version_message(consts::VERSION_MESSAGE),
global_setting(AppSettings::ColoredHelp),
global_setting(AppSettings::ColorAuto)
)]
2019-05-24 10:25:55 +02:00
pub(crate) struct Opt {
#[structopt(
long = "unstable",
short = "u",
help = "Enable unstable features.",
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."
)]
2019-05-24 10:25:55 +02:00
unstable: bool,
#[structopt(
long = "color",
default_value = use_color::AUTO,
set = ArgSettings::CaseInsensitive,
possible_values = use_color::VALUES,
help = "Print colorful output.",
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`.",
)]
pub(crate) use_color: UseColor,
2019-05-24 10:25:55 +02:00
#[structopt(subcommand)]
subcommand: Subcommand,
}
impl Opt {
pub(crate) fn run(self, env: &mut Env) -> Result<(), Error> {
2019-05-24 10:25:55 +02:00
self.subcommand.run(env, self.unstable)
}
}