From d1ac6d7263c78538414f0c944b8f6ca50a8c286e Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Thu, 6 Feb 2025 21:09:12 -0600 Subject: wip: some changes --- ozone-cli/src/main.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'ozone-cli/src/main.rs') diff --git a/ozone-cli/src/main.rs b/ozone-cli/src/main.rs index 346532a..4b04e48 100644 --- a/ozone-cli/src/main.rs +++ b/ozone-cli/src/main.rs @@ -15,7 +15,7 @@ async fn main_inner(cli: Cli) -> Result> { }; info!("Sensible home could be {home:?}"); - let settings = Settings::load(home.join("ozone.json")).await?; + let mut settings = Settings::load(home.join("ozone.json")).await?; match &cli.subcmd { RootCommand::Profile(p) => match p.command() { @@ -23,6 +23,27 @@ async fn main_inner(cli: Cli) -> Result> { for (name, profile) in settings.get_profiles().iter() { println!("{name}: {profile:#?}"); } + }, + ProfileCommand::Create(args) => { + if settings.profiles.contains_key(&args.name) { + eprintln!("A profile with that name already exists."); + return Ok(ExitCode::FAILURE); + } + + if let Some(ref src) = args.clone { + if let Some(profile) = settings.get_profiles().get(src) { + let profile = profile.clone(); + settings.profiles.insert(args.name.clone(), profile); + } else { + eprintln!("Unknown profile `{src}'."); + return Ok(ExitCode::FAILURE); + } + + return Ok(ExitCode::SUCCESS); + } + + // creating a new profile from scratch + } _ => todo!() }, -- cgit v1.2.3-70-g09d2