diff --git a/cuddle_cli/src/actions/shell.rs b/cuddle_cli/src/actions/shell.rs index a88e48b..d9f9f9a 100644 --- a/cuddle_cli/src/actions/shell.rs +++ b/cuddle_cli/src/actions/shell.rs @@ -1,7 +1,7 @@ use std::{ env::current_dir, path::PathBuf, - process::{Command, ExitStatus}, + process::{Command}, }; use crate::model::CuddleVariable; diff --git a/cuddle_cli/src/cli/mod.rs b/cuddle_cli/src/cli/mod.rs index fdf25ef..a67eb6d 100644 --- a/cuddle_cli/src/cli/mod.rs +++ b/cuddle_cli/src/cli/mod.rs @@ -167,7 +167,7 @@ impl CuddleCli { } pub fn execute(self) -> anyhow::Result { - if let Some(mut cli) = self.command.clone() { + if let Some(cli) = self.command.clone() { let matches = cli.clone().get_matches(); let res = match matches.subcommand() { diff --git a/cuddle_cli/src/cli/subcommands/init.rs b/cuddle_cli/src/cli/subcommands/init.rs index 20f24d0..6e64f6f 100644 --- a/cuddle_cli/src/cli/subcommands/init.rs +++ b/cuddle_cli/src/cli/subcommands/init.rs @@ -5,7 +5,7 @@ use clap::{ArgMatches, Command}; use crate::cli::CuddleCli; -pub fn build_command(root_cmd: Command, cli: CuddleCli) -> Command { +pub fn build_command(root_cmd: Command, _cli: CuddleCli) -> Command { let mut repo_url = clap::Arg::new("repo").long("repo").short('r'); if let Ok(cuddle_template_url) = std::env::var("CUDDLE_TEMPLATE_URL") { @@ -14,7 +14,7 @@ pub fn build_command(root_cmd: Command, cli: CuddleCli) -> Command { repo_url = repo_url.required(true); } - let mut execute_cmd = Command::new("init") + let execute_cmd = Command::new("init") .about("init bootstraps a repository from a template") .arg(repo_url) .arg(clap::Arg::new("name")) @@ -23,7 +23,7 @@ pub fn build_command(root_cmd: Command, cli: CuddleCli) -> Command { root_cmd.subcommand(execute_cmd) } -pub fn execute_init(exe_submatch: &ArgMatches, cli: CuddleCli) -> anyhow::Result<()> { +pub fn execute_init(exe_submatch: &ArgMatches, _cli: CuddleCli) -> anyhow::Result<()> { let repo = exe_submatch.get_one::("repo").unwrap(); let name = exe_submatch.get_one::("name"); let path = exe_submatch.get_one::("path"); @@ -105,7 +105,7 @@ pub fn execute_init(exe_submatch: &ArgMatches, cli: CuddleCli) -> anyhow::Result } }; - let (name, template_dir, template) = template?; + let (_name, template_dir, _template) = template?; let path = match path { Some(path) => path.clone(), @@ -118,7 +118,14 @@ pub fn execute_init(exe_submatch: &ArgMatches, cli: CuddleCli) -> anyhow::Result create_dir_all(&path)?; let dir = std::fs::read_dir(&path)?; if dir.count() != 0 { - anyhow::bail!("Directory {} is not empty", &path); + for entry in read_dir(&path)? { + let entry = entry?; + if entry.file_name() == ".git" { + continue; + } else { + anyhow::bail!("Directory {} is not empty", &path); + } + } } for entry in read_dir(template_dir)? {