From 3828d718af1866920670b3cfe23c85e2319811a2 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Tue, 14 Jan 2025 19:01:01 -0800 Subject: [PATCH] Clarify that `--ask` is meaningless `nh ... build` or `nh home build --dry`. This could be considered a bug report instead of a PR. I was confused for a while why nh was ignoring my `--ask`, but then realized I was doing `nh home build` instead of `nh home switch`. It seems like `--ask --dry` is valid for `nh darwin`, so it is allowed. --- src/darwin.rs | 9 +++++++-- src/home.rs | 12 ++++++++++-- src/nixos.rs | 10 +++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/darwin.rs b/src/darwin.rs index 25d5d7e..f64b2fe 100644 --- a/src/darwin.rs +++ b/src/darwin.rs @@ -1,5 +1,5 @@ use color_eyre::eyre::{bail, Context}; -use tracing::{debug, info}; +use tracing::{debug, info, warn}; use crate::commands; use crate::commands::Command; @@ -17,7 +17,12 @@ impl DarwinArgs { use DarwinRebuildVariant::*; match self.subcommand { DarwinSubcommand::Switch(args) => args.rebuild(Switch), - DarwinSubcommand::Build(args) => args.rebuild(Build), + DarwinSubcommand::Build(args) => { + if args.common.ask || args.common.dry { + warn!("`--ask` and `--dry` have no effect for `nh darwin build`"); + } + args.rebuild(Build) + } DarwinSubcommand::Repl(args) => args.run(), } } diff --git a/src/home.rs b/src/home.rs index 6bc2579..ec8235a 100644 --- a/src/home.rs +++ b/src/home.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use color_eyre::eyre::bail; use color_eyre::Result; -use tracing::{debug, info}; +use tracing::{debug, info, warn}; use crate::commands; use crate::commands::Command; @@ -16,7 +16,12 @@ impl interface::HomeArgs { use HomeRebuildVariant::*; match self.subcommand { HomeSubcommand::Switch(args) => args.rebuild(Switch), - HomeSubcommand::Build(args) => args.rebuild(Build), + HomeSubcommand::Build(args) => { + if args.common.ask || args.common.dry { + warn!("`--ask` and `--dry` have no effect for `nh home build`"); + } + args.rebuild(Build) + } HomeSubcommand::Repl(args) => args.run(), } } @@ -79,6 +84,9 @@ impl HomeRebuildArgs { } if self.common.dry || matches!(variant, Build) { + if self.common.ask { + warn!("--ask has no effect as dry run was requested"); + } return Ok(()); } diff --git a/src/nixos.rs b/src/nixos.rs index fd235b7..11476fe 100644 --- a/src/nixos.rs +++ b/src/nixos.rs @@ -25,7 +25,12 @@ impl interface::OsArgs { OsSubcommand::Boot(args) => args.rebuild(Boot), OsSubcommand::Test(args) => args.rebuild(Test), OsSubcommand::Switch(args) => args.rebuild(Switch), - OsSubcommand::Build(args) => args.rebuild(Build), + OsSubcommand::Build(args) => { + if args.common.ask || args.common.dry { + warn!("`--ask` and `--dry` have no effect for `nh os build`"); + } + args.rebuild(Build) + } OsSubcommand::Repl(args) => args.run(), OsSubcommand::Info(args) => args.info(), } @@ -112,6 +117,9 @@ impl OsRebuildArgs { .run()?; if self.common.dry || matches!(variant, Build) { + if self.common.ask { + warn!("--ask has no effect as dry run was requested"); + } return Ok(()); }