From d55555c1ed6ad8420fe51ebcff1b29bf9f77a505 Mon Sep 17 00:00:00 2001 From: i1i1 Date: Thu, 10 Aug 2023 01:56:36 +0300 Subject: [PATCH] Convert nix-info arguments to type-safe clap derive --- src/command/nix_info.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/command/nix_info.rs b/src/command/nix_info.rs index a4c0643..8857d5b 100644 --- a/src/command/nix_info.rs +++ b/src/command/nix_info.rs @@ -1,14 +1,22 @@ -use clap::{ArgMatches, Command as ClapCommand}; +use clap::{ArgMatches, Args, FromArgMatches, Command}; use crate::error::ColmenaError; use crate::nix::evaluator::nix_eval_jobs::get_pinned_nix_eval_jobs; use crate::nix::NixCheck; -pub fn subcommand() -> ClapCommand { - ClapCommand::new("nix-info").about("Show information about the current Nix installation") +#[derive(Debug, Args)] +#[command( + name = "nix-info", + about = "Show information about the current Nix installation" +)] +pub struct Opts {} + +pub fn subcommand() -> Command { + Opts::augment_args(Command::new("nix-info")) } -pub async fn run(_global_args: &ArgMatches, _local_args: &ArgMatches) -> Result<(), ColmenaError> { +pub async fn run(_global_args: &ArgMatches, local_args: &ArgMatches) -> Result<(), ColmenaError> { + let Opts {} = Opts::from_arg_matches(local_args).unwrap(); let check = NixCheck::detect().await; check.print_version_info(); check.print_flakes_info(false);