diff options
| author | 2025-02-06 21:09:12 -0600 | |
|---|---|---|
| committer | 2025-02-06 21:09:12 -0600 | |
| commit | d1ac6d7263c78538414f0c944b8f6ca50a8c286e (patch) | |
| tree | 7609b379ed02da76c902033973ce12f98d06db03 /ozone-cli/src/main.rs | |
| parent | small cli changes (diff) | |
wip: some changes
Diffstat (limited to 'ozone-cli/src/main.rs')
| -rw-r--r-- | ozone-cli/src/main.rs | 23 |
1 files changed, 22 insertions, 1 deletions
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<ExitCode, Box<dyn Error>> { }; 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<ExitCode, Box<dyn Error>> { 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!() }, |
