diff options
Diffstat (limited to '')
-rw-r--r-- | pkgs/by-name/fu/fupdate/src/cli.rs | 10 | ||||
-rw-r--r-- | pkgs/by-name/fu/fupdate/src/main.rs | 33 |
2 files changed, 35 insertions, 8 deletions
diff --git a/pkgs/by-name/fu/fupdate/src/cli.rs b/pkgs/by-name/fu/fupdate/src/cli.rs index 6f970ac4..6ebd1bc4 100644 --- a/pkgs/by-name/fu/fupdate/src/cli.rs +++ b/pkgs/by-name/fu/fupdate/src/cli.rs @@ -1,3 +1,13 @@ +// nixos-config - My current NixOS configuration +// +// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> +// SPDX-License-Identifier: GPL-3.0-or-later +// +// This file is part of my nixos-config. +// +// You should have received a copy of the License along with this program. +// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. + use std::{env, ffi::OsStr, fs::read_dir}; use clap::Parser; diff --git a/pkgs/by-name/fu/fupdate/src/main.rs b/pkgs/by-name/fu/fupdate/src/main.rs index 850eaf87..b4af6cd6 100644 --- a/pkgs/by-name/fu/fupdate/src/main.rs +++ b/pkgs/by-name/fu/fupdate/src/main.rs @@ -1,3 +1,13 @@ +// nixos-config - My current NixOS configuration +// +// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> +// SPDX-License-Identifier: GPL-3.0-or-later +// +// This file is part of my nixos-config. +// +// You should have received a copy of the License along with this program. +// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. + use std::process::Command; use anyhow::{bail, Context, Result}; @@ -12,7 +22,7 @@ fn main() -> Result<(), anyhow::Error> { let args = CliArgs::parse(); - let other = args.command.first().map_or("flake", String::as_str); + let command = args.command.first().map_or("flake", String::as_str); { let args = if args.command.len() > 1 { @@ -21,20 +31,27 @@ fn main() -> Result<(), anyhow::Error> { &[] }; - let status = Command::new(format!("fupdate-{other}")) + // println!("Running: `fupdate-{command} {}`", args.join(" ")); + + let child = Command::new(format!("fupdate-{command}")) .args(args) .status() - .with_context(|| format!("Failed to execute `fupdate-{other}`"))?; + .with_context(|| format!("Failed to spawn `fupdate-{command}`"))?; - if !status.success() { - bail!("Command `fupdate-{other}` failed!"); + if !child.success() { + bail!("Command `fupdate-{command} {}` failed!", args.join(" ")); } } Ok(()) } -#[test] -fn verify_cli() { - CliArgs::command().debug_assert(); +#[cfg(test)] +mod test { + use clap::CommandFactory; + + #[test] + fn verify_cli() { + super::CliArgs::command().debug_assert(); + } } |