diff options
Diffstat (limited to 'dotup_cli/src/commands/init.rs')
| -rw-r--r-- | dotup_cli/src/commands/init.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/dotup_cli/src/commands/init.rs b/dotup_cli/src/commands/init.rs new file mode 100644 index 0000000..bfec6ca --- /dev/null +++ b/dotup_cli/src/commands/init.rs | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | use clap::Clap; | ||
| 2 | |||
| 3 | use super::prelude::*; | ||
| 4 | |||
| 5 | #[derive(Clap)] | ||
| 6 | pub struct Opts {} | ||
| 7 | |||
| 8 | pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { | ||
| 9 | if !dotup::utils::is_file(&config.archive_path)? { | ||
| 10 | let archive = Archive::default(); | ||
| 11 | log::info!("Creating archive"); | ||
| 12 | utils::write_archive(&config.archive_path, &archive)?; | ||
| 13 | } else { | ||
| 14 | log::info!( | ||
| 15 | "Archive file already exists : {}", | ||
| 16 | config.archive_path.display() | ||
| 17 | ); | ||
| 18 | } | ||
| 19 | Ok(()) | ||
| 20 | } | ||
