Skip to content

Commit 5399ac8

Browse files
author
rzmk
committed
feat: add --debug flag
1 parent 4f00300 commit 5399ac8

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/main.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ fn main() {
1111
if dry_run {
1212
println!("Running in dry run mode\n");
1313
}
14+
// Check if --debug flag is passed to run in debug mode
15+
let debug = args.len() > 1 && args.contains(&String::from("--debug"));
1416

1517
// Commit Type
1618
let commit_type_options = vec![
@@ -46,19 +48,33 @@ fn main() {
4648
if run_git_add == true {
4749
println!("Running git add -A");
4850
if !dry_run {
49-
Command::new("git")
51+
let output = Command::new("git")
5052
.args(["add", "-A"])
5153
.output()
5254
.expect("failed to execute process");
55+
56+
if debug {
57+
println!("Debug info:");
58+
println!("stdout:\n{}", String::from_utf8_lossy(&output.stdout));
59+
println!("stderr:\n{}", String::from_utf8_lossy(&output.stderr));
60+
println!("Exit status:\n{}", output.status);
61+
}
5362
}
5463
}
5564

5665
println!("Running git commit -m \"{}\"", result_message);
5766
if dry_run == false {
58-
Command::new("git")
67+
let output = Command::new("git")
5968
.args(["commit", "-m", result_message.as_str()])
6069
.output()
6170
.expect("failed to execute process");
71+
72+
if debug {
73+
println!("Debug info:");
74+
println!("stdout:\n{}", String::from_utf8_lossy(&output.stdout));
75+
println!("stderr:\n{}", String::from_utf8_lossy(&output.stderr));
76+
println!("Exit status:\n{}", output.status);
77+
}
6278
}
6379
}
6480
_ => {

0 commit comments

Comments
 (0)