diff options
| -rw-r--r-- | src/bin/ngit/cli.rs | 3 | ||||
| -rw-r--r-- | src/bin/ngit/main.rs | 8 |
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 | ||
| 47 | pub const CUSTOMISE_TEMPLATE: &str = r" | 50 | pub 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 | ||
| 16 | mod sub_commands; | 16 | mod sub_commands; |
| 17 | 17 | ||
| 18 | fn 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] |
| 19 | async fn main() { | 23 | async 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 |