summaryrefslogtreecommitdiff
path: root/src/dev/new.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-22 00:38:34 +0200
committermo8it <mo8it@proton.me>2024-04-22 00:38:34 +0200
commit4ce2714da1f079e81b6887b52b1acfbc283a3d63 (patch)
tree1aa07300ef55bfa5d6001f32761e6750ae323794 /src/dev/new.rs
parente93a99e19e5f1a5dee6b28ed2f703bff57038b11 (diff)
Add --no-git
Diffstat (limited to 'src/dev/new.rs')
-rw-r--r--src/dev/new.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/dev/new.rs b/src/dev/new.rs
index b0828a4..82aba42 100644
--- a/src/dev/new.rs
+++ b/src/dev/new.rs
@@ -26,7 +26,7 @@ where
Ok(())
}
-pub fn new(path: &Path) -> Result<()> {
+pub fn new(path: &Path, no_git: bool) -> Result<()> {
let dir_name = path.to_string_lossy();
create_dir(path).with_context(|| format!("Failed to create the directory {dir_name}"))?;
@@ -35,11 +35,12 @@ pub fn new(path: &Path) -> Result<()> {
set_current_dir(path)
.with_context(|| format!("Failed to set {dir_name} as the current directory"))?;
- if !Command::new("git")
- .arg("init")
- .status()
- .context("Failed to run `git init`")?
- .success()
+ if !no_git
+ && !Command::new("git")
+ .arg("init")
+ .status()
+ .context("Failed to run `git init`")?
+ .success()
{
bail!("`git init` didn't run successfully. See the error message above");
}