diff options
| author | Fuwn <[email protected]> | 2022-02-08 17:57:07 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-06-09 00:46:07 -0700 |
| commit | dbe0fc25d5680cc5262fb8e9c7bbc55c8b3a1a71 (patch) | |
| tree | 5a49f406673072203ed8088d0b53f439f223abbb /crates | |
| parent | ci(release.yaml): enable on workflow_dispatch (diff) | |
| download | archived-divina-dbe0fc25d5680cc5262fb8e9c7bbc55c8b3a1a71.tar.xz archived-divina-dbe0fc25d5680cc5262fb8e9c7bbc55c8b3a1a71.zip | |
feat(cli): check before initing, no overwrite
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/divina/src/cli.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/divina/src/cli.rs b/crates/divina/src/cli.rs index 5cc273e..4cbb6c7 100644 --- a/crates/divina/src/cli.rs +++ b/crates/divina/src/cli.rs @@ -1,6 +1,8 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only +use std::path::Path; + use structopt::clap::{App, AppSettings, Arg, SubCommand}; /// Create CLI @@ -53,8 +55,17 @@ pub fn execute(divina: &mut crate::Divina) { .unwrap_or("https://github.com/divinaland/init.git"); let path = init_matches.value_of("path").unwrap_or("."); + if Path::new("Divina.lua").exists() { + println!( + "!! could not clone init repository to '{}', a 'Divina.lua' already exists", + path + ); + + std::process::exit(1); + } + divina_git::clone(repository, &format!("./{}", path)) - .expect("!! could to clone init repository, perhaps the repository is invalid ?"); + .expect("!! could not clone init repository, perhaps the repository is invalid ?"); } ("build", Some(_build_matches)) => { divina @@ -64,7 +75,7 @@ pub fn execute(divina: &mut crate::Divina) { .link(); } ("clean", Some(_clean_matches)) => - if std::path::Path::new("out/").exists() { + if Path::new("out/").exists() { println!(":: removing directory 'out/'"); std::fs::remove_dir_all("out/") .expect("!! could not remove directory 'out/', check permissions"); |