@@ -2,10 +2,9 @@ use crate::commands::{Command, CommandType};
22use crate :: utils:: error;
33use crate :: utils:: error:: ErrorCode ;
44
5-
65/// Print usage text and exit with non-zero code.
76fn print_usage ( any_code : Option < ErrorCode > ) {
8- let help = r#"Usage: bm <asdc> [name] [directory]
7+ let help = r#"Usage: bm [debug] <asdc> [name] [directory]
98 For detailed help, type `bm help`
109 "# ;
1110 print ! ( "{}\n " , help) ;
@@ -15,9 +14,18 @@ fn print_usage(any_code : Option<ErrorCode>) {
1514 }
1615}
1716
18- pub fn parse_cli_options ( ) -> Command {
17+ pub fn parse_cli_options ( ) -> ( Command , bool ) {
1918 let mut command: Command = Command :: new ( CommandType :: NONE , None ) ;
2019 let mut arguments : Vec < String > = std:: env:: args ( ) . collect ( ) ;
20+ let mut command_index = 1 ;
21+ let mut debug_mode = false ;
22+
23+ if arguments. len ( ) > 1 && arguments[ 1 ] == "debug" {
24+ println ! ( "[DBG|Debug Mode]" ) ;
25+ arguments. remove ( 1 ) ;
26+ command_index = 2 ;
27+ debug_mode = true ;
28+ }
2129
2230 // No argument is given.
2331 // ./bm
@@ -36,7 +44,7 @@ pub fn parse_cli_options() -> Command {
3644 args_options = Some ( arguments) ;
3745 }
3846
39- match std:: env:: args ( ) . nth ( 1 ) . as_deref ( ) {
47+ match std:: env:: args ( ) . nth ( command_index ) . as_deref ( ) {
4048 Some ( "h" ) | Some ( "help" ) | Some ( "-h" ) | Some ( "--help" ) => {
4149 command = Command :: new ( CommandType :: HELP , None ) ; // args_option = None
4250 }
@@ -61,5 +69,5 @@ pub fn parse_cli_options() -> Command {
6169 print_usage ( None ) ;
6270 }
6371 }
64- command
72+ ( command, debug_mode )
6573}
0 commit comments