From cdfc1f15a1727e895dc455c0d2f05a18c4719528 Mon Sep 17 00:00:00 2001 From: i1i1 Date: Thu, 10 Aug 2023 01:28:41 +0300 Subject: [PATCH] Convert build arguments to type-safe clap derive --- src/command/build.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/command/build.rs b/src/command/build.rs index 8bbf4fa..170c435 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -1,25 +1,25 @@ -use clap::{builder::PossibleValuesParser, Arg, Args, Command as ClapCommand}; +use clap::{Args, Command as ClapCommand}; -use crate::util; +use crate::nix::Goal; pub use super::apply::run; use super::apply::DeployOpts; -pub fn subcommand() -> ClapCommand { - let command = ClapCommand::new("build") - .about("Build configurations but not push to remote machines") - .long_about( - r#"Build configurations but not push to remote machines +#[derive(Debug, Args)] +#[command( + name = "build", + about = "Build configurations but not push to remote machines", + long_about = r#"Build configurations but not push to remote machines -This subcommand behaves as if you invoked `apply` with the `build` goal."#, - ) - .arg( - Arg::new("goal") - .hide(true) - .default_value("build") - .value_parser(PossibleValuesParser::new(["build"])) - .num_args(1), - ); - - util::register_selector_args(DeployOpts::augment_args_for_update(command)) +This subcommand behaves as if you invoked `apply` with the `build` goal."# +)] +pub struct Opts { + #[command(flatten)] + deploy: DeployOpts, + #[arg(hide = true, default_value_t = Goal::Build)] + goal: Goal, +} + +pub fn subcommand() -> ClapCommand { + Opts::augment_args(ClapCommand::new("build")) }