feat: add --debug flag

This commit is contained in:
rzmk 2023-11-29 17:14:42 -05:00
parent 4f00300d9c
commit 5399ac86d0
No known key found for this signature in database

View file

@ -11,6 +11,8 @@ fn main() {
if dry_run { if dry_run {
println!("Running in dry run mode\n"); println!("Running in dry run mode\n");
} }
// Check if --debug flag is passed to run in debug mode
let debug = args.len() > 1 && args.contains(&String::from("--debug"));
// Commit Type // Commit Type
let commit_type_options = vec![ let commit_type_options = vec![
@ -46,19 +48,33 @@ fn main() {
if run_git_add == true { if run_git_add == true {
println!("Running git add -A"); println!("Running git add -A");
if !dry_run { if !dry_run {
Command::new("git") let output = Command::new("git")
.args(["add", "-A"]) .args(["add", "-A"])
.output() .output()
.expect("failed to execute process"); .expect("failed to execute process");
if debug {
println!("Debug info:");
println!("stdout:\n{}", String::from_utf8_lossy(&output.stdout));
println!("stderr:\n{}", String::from_utf8_lossy(&output.stderr));
println!("Exit status:\n{}", output.status);
}
} }
} }
println!("Running git commit -m \"{}\"", result_message); println!("Running git commit -m \"{}\"", result_message);
if dry_run == false { if dry_run == false {
Command::new("git") let output = Command::new("git")
.args(["commit", "-m", result_message.as_str()]) .args(["commit", "-m", result_message.as_str()])
.output() .output()
.expect("failed to execute process"); .expect("failed to execute process");
if debug {
println!("Debug info:");
println!("stdout:\n{}", String::from_utf8_lossy(&output.stdout));
println!("stderr:\n{}", String::from_utf8_lossy(&output.stderr));
println!("Exit status:\n{}", output.status);
}
} }
} }
_ => { _ => {