diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-09-08 17:47:14 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-09-08 17:47:14 +0300 |
commit | 2654c57e25218247abbec6864b857d1d95493cac (patch) | |
tree | 09c608ef68974a55984e52ab316e8428f864e4dd /src | |
parent | 1be7278231da7274b03cd4456f9a806ca098d8aa (diff) | |
download | vmadm-2654c57e25218247abbec6864b857d1d95493cac.tar.gz |
refactor: use current clap instead of structopt for command line
Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/vmadm.rs | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/src/bin/vmadm.rs b/src/bin/vmadm.rs index a693b96..a10d3d9 100644 --- a/src/bin/vmadm.rs +++ b/src/bin/vmadm.rs @@ -1,8 +1,8 @@ use anyhow::Context; +use clap::Parser; use directories_next::ProjectDirs; use log::debug; use std::path::PathBuf; -use structopt::StructOpt; use vmadm::cmd; use vmadm::config::Configuration; use vmadm::progress::{MessageKind, Progress}; @@ -12,99 +12,90 @@ const QUALIFIER: &str = ""; const ORG: &str = ""; const APP: &str = "vmadm"; -#[derive(StructOpt, Debug)] +#[derive(Debug, Parser)] struct Cli { - #[structopt(subcommand)] + #[clap(subcommand)] cmd: Command, } -#[derive(StructOpt, Debug)] +#[derive(Debug, Parser)] enum Command { New { - #[structopt(flatten)] + #[clap(flatten)] common: CommonOptions, - #[structopt(parse(from_os_str))] specs: Vec<PathBuf>, }, Recreate { - #[structopt(flatten)] + #[clap(flatten)] common: CommonOptions, - #[structopt(parse(from_os_str))] specs: Vec<PathBuf>, }, Config { - #[structopt(flatten)] + #[clap(flatten)] common: CommonOptions, }, Spec { - #[structopt(flatten)] + #[clap(flatten)] common: CommonOptions, - #[structopt(parse(from_os_str))] spec: PathBuf, }, List { - #[structopt(flatten)] + #[clap(flatten)] common: CommonOptions, }, Delete { - #[structopt(flatten)] + #[clap(flatten)] common: CommonOptions, - #[structopt(parse(from_os_str))] specs: Vec<PathBuf>, }, Start { - #[structopt(flatten)] + #[clap(flatten)] common: CommonOptions, - #[structopt(parse(from_os_str))] specs: Vec<PathBuf>, }, Shutdown { - #[structopt(flatten)] + #[clap(flatten)] common: CommonOptions, - #[structopt(parse(from_os_str))] specs: Vec<PathBuf>, }, CloudInit { - #[structopt(flatten)] + #[clap(flatten)] common: CommonOptions, - #[structopt(parse(from_os_str))] spec: PathBuf, - - #[structopt(parse(from_os_str))] dirname: PathBuf, }, } -#[derive(StructOpt, Debug)] +#[derive(Debug, Parser)] struct CommonOptions { - #[structopt(short, long, parse(from_os_str))] + #[clap(short, long)] config: Option<PathBuf>, - #[structopt(short, long)] + #[clap(short, long)] quiet: bool, - #[structopt(short, long)] + #[clap(short, long)] verbose: bool, } fn main() -> anyhow::Result<()> { pretty_env_logger::init_custom_env("VMADM_LOG"); - let cli = Cli::from_args(); + let cli = Cli::parse(); debug!("{:#?}", cli); match cli.cmd { |