diff --git a/src/clean.rs b/src/clean.rs index 2b99a56..a84f35f 100644 --- a/src/clean.rs +++ b/src/clean.rs @@ -252,7 +252,7 @@ fn profiles_in_dir + fmt::Debug>(dir: P) -> Vec { let generation_regex = Regex::new(r"^(.*)-(\d+)-link$").unwrap(); - if let Some(_) = generation_regex.captures(&name) { + if generation_regex.captures(&name).is_some() { res.push(path); } } diff --git a/src/darwin.rs b/src/darwin.rs new file mode 100644 index 0000000..4e5e963 --- /dev/null +++ b/src/darwin.rs @@ -0,0 +1,30 @@ +use crate::interface::{DarwinArgs, DarwinRebuildArgs, DarwinReplArgs, DarwinSubcommand}; +use crate::Result; + +impl DarwinArgs { + pub fn run(self) -> Result<()> { + use DarwinRebuildVariant::*; + match self.subcommand { + DarwinSubcommand::Switch(args) => args.rebuild(Switch), + DarwinSubcommand::Build(args) => args.rebuild(Build), + DarwinSubcommand::Repl(args) => args.run(), + } + } +} + +enum DarwinRebuildVariant { + Switch, + Build, +} + +impl DarwinRebuildArgs { + fn rebuild(self, _variant: DarwinRebuildVariant) -> Result<()> { + todo!(); + } +} + +impl DarwinReplArgs { + fn run(self) -> Result<()> { + todo!(); + } +} diff --git a/src/home.rs b/src/home.rs index 4b205bd..ca628ac 100644 --- a/src/home.rs +++ b/src/home.rs @@ -10,11 +10,6 @@ use crate::commands::Command; use crate::installable::Installable; use crate::interface::{self, HomeRebuildArgs}; -const SYSTEM_PROFILE: &str = "/nix/var/nix/profiles/system"; -const CURRENT_PROFILE: &str = "/run/current-system"; - -const SPEC_LOCATION: &str = "/etc/specialisation"; - impl interface::HomeArgs { pub fn run(self) -> Result<()> { use HomeRebuildVariant::*; diff --git a/src/interface.rs b/src/interface.rs index f998768..1a336b7 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -44,9 +44,10 @@ pub struct Main { #[command(disable_help_subcommand = true)] pub enum NHCommand { Os(OsArgs), + Home(HomeArgs), + Darwin(DarwinArgs), Search(SearchArgs), Clean(CleanProxy), - Home(HomeArgs), #[command(hide = true)] Completions(CompletionArgs), } @@ -59,6 +60,7 @@ impl NHCommand { NHCommand::Clean(proxy) => proxy.command.run(), NHCommand::Completions(args) => args.run(), NHCommand::Home(args) => args.run(), + NHCommand::Darwin(args) => args.run(), } } } @@ -279,3 +281,28 @@ pub struct CompletionArgs { /// Name of the shell pub shell: clap_complete::Shell, } + +#[derive(Debug, Args)] +pub struct DarwinArgs { + #[command(subcommand)] + pub subcommand: DarwinSubcommand, +} + +#[derive(Debug, Subcommand)] +pub enum DarwinSubcommand { + Switch(DarwinRebuildArgs), + Build(DarwinRebuildArgs), + Repl(DarwinReplArgs), +} + +#[derive(Debug, Args)] +pub struct DarwinRebuildArgs { + #[command(flatten)] + pub common: CommonRebuildArgs, +} + +#[derive(Debug, Args)] +pub struct DarwinReplArgs { + #[command(flatten)] + pub installable: Installable, +} diff --git a/src/main.rs b/src/main.rs index 1a42867..93368d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ mod clean; mod commands; mod completion; +mod darwin; mod home; mod installable; mod interface; diff --git a/src/search.rs b/src/search.rs index 9f511a8..726f566 100644 --- a/src/search.rs +++ b/src/search.rs @@ -1,7 +1,7 @@ use std::process::Stdio; use std::time::Instant; -use color_eyre::eyre::{bail, Context, ContextCompat}; +use color_eyre::eyre::{bail, Context}; use elasticsearch_dsl::*; use interface::SearchArgs; use regex::Regex;