Skip to content

Commit

Permalink
Clarify that --ask is meaningless nh ... build or `nh home build …
Browse files Browse the repository at this point in the history
…--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.
  • Loading branch information
ilyagr authored and viperML committed Jan 22, 2025
1 parent e691846 commit 3828d71
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/darwin.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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(),
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(),
}
}
Expand Down Expand Up @@ -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(());
}

Expand Down
10 changes: 9 additions & 1 deletion src/nixos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down Expand Up @@ -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(());
}

Expand Down

0 comments on commit 3828d71

Please sign in to comment.