summaryrefslogtreecommitdiff
path: root/src/bin/vmadm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/vmadm.rs')
-rw-r--r--src/bin/vmadm.rs62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/bin/vmadm.rs b/src/bin/vmadm.rs
index a693b96..b515e45 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,101 @@ 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 {
+ #[clap(visible_alias = "create")]
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,
},
+ #[clap(visible_alias = "remove")]
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>,
},
+ #[clap(visible_alias = "restart")]
+ Reboot {
+ #[clap(flatten)]
+ common: CommonOptions,
+
+ specs: Vec<PathBuf>,
+ },
+
+ #[clap(visible_alias = "stop")]
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 {
@@ -150,6 +152,12 @@ fn main() -> anyhow::Result<()> {
cmd::start(&specs, &progress)?;
}
+ Command::Reboot { common, specs } => {
+ let progress = get_progress(&common);
+ let specs = get_specs(&common, &specs)?;
+ cmd::reboot(&specs, &progress)?;
+ }
+
Command::Shutdown { common, specs } => {
let progress = get_progress(&common);
let specs = get_specs(&common, &specs)?;