diff options
Diffstat (limited to 'src/commands/profile.rs')
-rw-r--r-- | src/commands/profile.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/commands/profile.rs b/src/commands/profile.rs new file mode 100644 index 0000000..98fbc08 --- /dev/null +++ b/src/commands/profile.rs @@ -0,0 +1,22 @@ +use anyhow::Result; +use clap::ArgMatches; + +use crate::config::Config; +use crate::profile::Profile; + +pub async fn profile(matches: &ArgMatches) -> Result<()> { + match matches.subcommand() { + Some(("create", m)) => profile_create(m).await, + _ => unimplemented!(), + } +} + +async fn profile_create(matches: &ArgMatches) -> Result<()> { + let name = matches.value_of("name").map(String::from).unwrap(); // required + let state_dir = Profile::state_dir_path(&name)?; + log::info!("Creating '{}' in {}", name, state_dir.display()); + + let profile = Profile::create(&state_dir, &name, Config::default()).await?; + log::info!("Saving..."); + profile.save().await +} |