mirror of
https://github.com/rzmk/commit-helper.git
synced 2025-12-19 05:29:24 +00:00
refactor: consolidate debug print statements to a single function
This commit is contained in:
parent
c48139ebc6
commit
0d5ebd26ac
1 changed files with 10 additions and 12 deletions
22
src/main.rs
22
src/main.rs
|
|
@ -1,6 +1,13 @@
|
||||||
use inquire::{Confirm, Select};
|
use inquire::{Confirm, Select};
|
||||||
use std::{env, process::Command};
|
use std::{env, process::Command};
|
||||||
|
|
||||||
|
fn print_debug_info(output: std::process::Output) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Check if -a flag is passed to run git add -A before commit
|
// Check if -a flag is passed to run git add -A before commit
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
@ -69,10 +76,7 @@ fn main() {
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process");
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
println!("Debug info:");
|
print_debug_info(output);
|
||||||
println!("stdout:\n{}", String::from_utf8_lossy(&output.stdout));
|
|
||||||
println!("stderr:\n{}", String::from_utf8_lossy(&output.stderr));
|
|
||||||
println!("Exit status:\n{}", output.status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,10 +89,7 @@ fn main() {
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process");
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
println!("Debug info:");
|
print_debug_info(output);
|
||||||
println!("stdout:\n{}", String::from_utf8_lossy(&output.stdout));
|
|
||||||
println!("stderr:\n{}", String::from_utf8_lossy(&output.stderr));
|
|
||||||
println!("Exit status:\n{}", output.status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,10 +102,7 @@ fn main() {
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process");
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
println!("Debug info:");
|
print_debug_info(output);
|
||||||
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