From ce0782ccace715d7df7264e17e5307eba62d8e5b Mon Sep 17 00:00:00 2001 From: i1i1 Date: Thu, 10 Aug 2023 02:02:18 +0300 Subject: [PATCH] Fix upload-keys command --- src/command/repl.rs | 7 +++---- src/command/upload_keys.rs | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/command/repl.rs b/src/command/repl.rs index c132cdc..5a3e25c 100644 --- a/src/command/repl.rs +++ b/src/command/repl.rs @@ -1,6 +1,6 @@ use std::io::Write; -use clap::{ArgMatches, Command as ClapCommand, FromArgMatches, Args}; +use clap::{ArgMatches, Args, Command as ClapCommand, FromArgMatches}; use tempfile::Builder as TempFileBuilder; use tokio::process::Command; @@ -12,12 +12,11 @@ use crate::nix::info::NixCheck; #[command( name = "repl", about = "Start an interactive REPL with the complete configuration", - long_about = - r#"Start an interactive REPL with the complete configuration + long_about = r#"Start an interactive REPL with the complete configuration In the REPL, you can inspect the configuration interactively with tab completion. The node configurations are accessible under the `nodes` -attribute set."#, +attribute set."# )] pub struct Opts {} diff --git a/src/command/upload_keys.rs b/src/command/upload_keys.rs index 16555d4..2ce213f 100644 --- a/src/command/upload_keys.rs +++ b/src/command/upload_keys.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, util}; pub use super::apply::run; use super::apply::DeployOpts; -pub fn subcommand() -> ClapCommand { - let command = ClapCommand::new("upload-keys") - .about("Upload keys to remote hosts") - .long_about( - r#"Upload keys to remote hosts +#[derive(Debug, Args)] +#[command( + name = "upload-keys", + about = "Upload keys to remote hosts", + long_about = r#"Upload keys to remote hosts -This subcommand behaves as if you invoked `apply` with the pseudo `keys` goal."#, - ) - .arg( - Arg::new("goal") - .hide(true) - .default_value("keys") - .value_parser(PossibleValuesParser::new(["keys"])) - .num_args(1), - ); - - util::register_selector_args(DeployOpts::augment_args_for_update(command)) +This subcommand behaves as if you invoked `apply` with the pseudo `keys` 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("upload-keys")) }