upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/ngit
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-13 08:12:05 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-13 08:12:05 +0000
commitcfd8cc19b6a81ad78bc30d5b21cefe21d574d09e (patch)
tree1c87060ebc36da51e17bbb3ac246e77035ee362c /src/bin/ngit
parent64f1cf4f8e021f52f8e7df75e62f10d32d9fa101 (diff)
feat: add --verbose/-v flag for detailed output
Adds a global --verbose/-v flag that sets NGIT_VERBOSE environment variable. Also sets NGIT_VERBOSE automatically when NGIT_TEST is set.
Diffstat (limited to 'src/bin/ngit')
-rw-r--r--src/bin/ngit/cli.rs3
-rw-r--r--src/bin/ngit/main.rs8
2 files changed, 11 insertions, 0 deletions
diff --git a/src/bin/ngit/cli.rs b/src/bin/ngit/cli.rs
index dd7196c..c77e719 100644
--- a/src/bin/ngit/cli.rs
+++ b/src/bin/ngit/cli.rs
@@ -42,6 +42,9 @@ pub struct Cli {
42 /// Force operations, bypass safety guards 42 /// Force operations, bypass safety guards
43 #[arg(short = 'f', long, global = true)] 43 #[arg(short = 'f', long, global = true)]
44 pub force: bool, 44 pub force: bool,
45 /// Enable verbose output
46 #[arg(short = 'v', long, global = true)]
47 pub verbose: bool,
45} 48}
46 49
47pub const CUSTOMISE_TEMPLATE: &str = r" 50pub const CUSTOMISE_TEMPLATE: &str = r"
diff --git a/src/bin/ngit/main.rs b/src/bin/ngit/main.rs
index f405e94..65f6bca 100644
--- a/src/bin/ngit/main.rs
+++ b/src/bin/ngit/main.rs
@@ -15,6 +15,10 @@ use ngit::{
15 15
16mod sub_commands; 16mod sub_commands;
17 17
18fn is_verbose() -> bool {
19 std::env::var("NGIT_VERBOSE").is_ok() || std::env::var("NGIT_TEST").is_ok()
20}
21
18#[tokio::main] 22#[tokio::main]
19async fn main() { 23async fn main() {
20 let cli = Cli::parse(); 24 let cli = Cli::parse();
@@ -25,6 +29,10 @@ async fn main() {
25 std::env::set_var("NGIT_INTERACTIVE_MODE", "1"); 29 std::env::set_var("NGIT_INTERACTIVE_MODE", "1");
26 } 30 }
27 31
32 if cli.verbose || std::env::var("NGIT_TEST").is_ok() {
33 std::env::set_var("NGIT_VERBOSE", "1");
34 }
35
28 if cli.customize { 36 if cli.customize {
29 print!("{CUSTOMISE_TEMPLATE}"); 37 print!("{CUSTOMISE_TEMPLATE}");
30 std::process::exit(0); // Exit the program 38 std::process::exit(0); // Exit the program