mirror of
https://github.com/rzmk/commit-helper.git
synced 2025-12-19 05:29:24 +00:00
feat: add --debug flag
This commit is contained in:
parent
4f00300d9c
commit
5399ac86d0
1 changed files with 18 additions and 2 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue