diff options
| author | Mel <einebeere@gmail.com> | 2021-09-20 22:25:55 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2021-09-20 22:25:55 +0200 |
| commit | c25d22681f9bc6ddba512895182af0ce0252731b (patch) | |
| tree | eadcdec7d0b4d26d59e77169bd89b8db13e22fb6 /src/actions/create.rs | |
| parent | 8bcbf51cf4f7924600eae39db67ff653b48ad95d (diff) | |
| download | ka-c25d22681f9bc6ddba512895182af0ce0252731b.tar.zst ka-c25d22681f9bc6ddba512895182af0ce0252731b.zip | |
Split out common logic
Diffstat (limited to 'src/actions/create.rs')
| -rw-r--r-- | src/actions/create.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/actions/create.rs b/src/actions/create.rs new file mode 100644 index 0000000..26d20c8 --- /dev/null +++ b/src/actions/create.rs @@ -0,0 +1,20 @@ +use std::{fs, io}; + +use crate::{actions::update, files::Locations}; + +use super::ActionOptions; + +pub fn create(command_options: ActionOptions) -> io::Result<()> { + let locations = Locations::from(&command_options); + + if locations.ka_path.exists() { + fs::remove_dir_all(locations.ka_path.as_path())?; + } + + fs::create_dir(locations.ka_path)?; + fs::create_dir(locations.ka_files_path)?; + + update(command_options)?; + + Ok(()) +} |
