From 303cf14fc6b48f3733bc29f0f7614bc12db6a836 Mon Sep 17 00:00:00 2001 From: i1i1 Date: Fri, 11 Aug 2023 15:41:41 +0300 Subject: [PATCH] Remove empty options for subcommands --- src/cli.rs | 17 +++++++++++++---- src/command/nix_info.rs | 13 ++----------- src/command/repl.rs | 17 ++--------------- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index e9d74a5..aec55e5 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -182,8 +182,17 @@ This subcommand behaves as if you invoked `apply` with the pseudo `keys` goal."# deploy: DeployOpts, }, Exec(command::exec::Opts), - Repl(command::repl::Opts), - NixInfo(command::nix_info::Opts), + #[command( + about = "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."# + )] + Repl, + #[command(about = "Show information about the current Nix installation")] + NixInfo, #[cfg(debug_assertions)] #[command(about = "Run progress spinner tests", hide = true)] TestProgress, @@ -276,8 +285,8 @@ pub async fn run() { Command::ApplyLocal(args) => r(command::apply_local::run(hive, args), opts.config).await, Command::Eval(args) => r(command::eval::run(hive, args), opts.config).await, Command::Exec(args) => r(command::exec::run(hive, args), opts.config).await, - Command::NixInfo(args) => r(command::nix_info::run(args), opts.config).await, - Command::Repl(args) => r(command::repl::run(hive, args), opts.config).await, + Command::NixInfo => r(command::nix_info::run(), opts.config).await, + Command::Repl => r(command::repl::run(hive), opts.config).await, Command::TestProgress => r(command::test_progress::run(), opts.config).await, Command::Build { deploy } => { let args = command::apply::Opts { diff --git a/src/command/nix_info.rs b/src/command/nix_info.rs index ea0b240..c63c9f2 100644 --- a/src/command/nix_info.rs +++ b/src/command/nix_info.rs @@ -1,17 +1,8 @@ -use clap::Args; - -use crate::error::ColmenaError; +use crate::error::ColmenaResult; use crate::nix::evaluator::nix_eval_jobs::get_pinned_nix_eval_jobs; use crate::nix::NixCheck; -#[derive(Debug, Args)] -#[command( - name = "nix-info", - about = "Show information about the current Nix installation" -)] -pub struct Opts {} - -pub async fn run(_: Opts) -> Result<(), ColmenaError> { +pub async fn run() -> ColmenaResult<()> { let check = NixCheck::detect().await; check.print_version_info(); check.print_flakes_info(false); diff --git a/src/command/repl.rs b/src/command/repl.rs index a9240d7..28e6e45 100644 --- a/src/command/repl.rs +++ b/src/command/repl.rs @@ -1,26 +1,13 @@ use std::io::Write; -use clap::Args; use tempfile::Builder as TempFileBuilder; use tokio::process::Command; -use crate::error::ColmenaError; +use crate::error::ColmenaResult; use crate::nix::info::NixCheck; use crate::nix::Hive; -#[derive(Debug, Args)] -#[command( - name = "repl", - about = "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."# -)] -pub struct Opts {} - -pub async fn run(hive: Hive, _: Opts) -> Result<(), ColmenaError> { +pub async fn run(hive: Hive) -> ColmenaResult<()> { let nix_check = NixCheck::detect().await; let nix_version = nix_check.version().expect("Could not detect Nix version");