diff options
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!() }, |
