chore: cargo fix
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
6c5fed87b1
commit
2f2fdb9631
@ -1,7 +1,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
env::current_dir,
|
env::current_dir,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
process::{Command, ExitStatus},
|
process::{Command},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::model::CuddleVariable;
|
use crate::model::CuddleVariable;
|
||||||
|
@ -167,7 +167,7 @@ impl CuddleCli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(self) -> anyhow::Result<Self> {
|
pub fn execute(self) -> anyhow::Result<Self> {
|
||||||
if let Some(mut cli) = self.command.clone() {
|
if let Some(cli) = self.command.clone() {
|
||||||
let matches = cli.clone().get_matches();
|
let matches = cli.clone().get_matches();
|
||||||
|
|
||||||
let res = match matches.subcommand() {
|
let res = match matches.subcommand() {
|
||||||
|
@ -5,7 +5,7 @@ use clap::{ArgMatches, Command};
|
|||||||
|
|
||||||
use crate::cli::CuddleCli;
|
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');
|
let mut repo_url = clap::Arg::new("repo").long("repo").short('r');
|
||||||
|
|
||||||
if let Ok(cuddle_template_url) = std::env::var("CUDDLE_TEMPLATE_URL") {
|
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);
|
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")
|
.about("init bootstraps a repository from a template")
|
||||||
.arg(repo_url)
|
.arg(repo_url)
|
||||||
.arg(clap::Arg::new("name"))
|
.arg(clap::Arg::new("name"))
|
||||||
@ -23,7 +23,7 @@ pub fn build_command(root_cmd: Command, cli: CuddleCli) -> Command {
|
|||||||
root_cmd.subcommand(execute_cmd)
|
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::<String>("repo").unwrap();
|
let repo = exe_submatch.get_one::<String>("repo").unwrap();
|
||||||
let name = exe_submatch.get_one::<String>("name");
|
let name = exe_submatch.get_one::<String>("name");
|
||||||
let path = exe_submatch.get_one::<String>("path");
|
let path = exe_submatch.get_one::<String>("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 {
|
let path = match path {
|
||||||
Some(path) => path.clone(),
|
Some(path) => path.clone(),
|
||||||
@ -118,8 +118,15 @@ pub fn execute_init(exe_submatch: &ArgMatches, cli: CuddleCli) -> anyhow::Result
|
|||||||
create_dir_all(&path)?;
|
create_dir_all(&path)?;
|
||||||
let dir = std::fs::read_dir(&path)?;
|
let dir = std::fs::read_dir(&path)?;
|
||||||
if dir.count() != 0 {
|
if dir.count() != 0 {
|
||||||
|
for entry in read_dir(&path)? {
|
||||||
|
let entry = entry?;
|
||||||
|
if entry.file_name() == ".git" {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
anyhow::bail!("Directory {} is not empty", &path);
|
anyhow::bail!("Directory {} is not empty", &path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for entry in read_dir(template_dir)? {
|
for entry in read_dir(template_dir)? {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
|
Loading…
Reference in New Issue
Block a user