@@ -43,7 +43,8 @@ const PARSEARGS_SHELL_VAR: &str = "PARSEARGS_SHELL";
43
43
) ]
44
44
#[ command( version) ]
45
45
struct CmdLineArgs {
46
- /// Definition of supported shell options
46
+ /// Definition of supported shell options.
47
+ /// Can be given multiple times.
47
48
#[ arg( short = 'o' , long = "options" , value_name = "OPT-DEFs" ) ]
48
49
options_list : Option < Vec < String > > ,
49
50
@@ -65,7 +66,7 @@ struct CmdLineArgs {
65
66
#[ arg( short = 'r' , long = "remainder" , value_name = "SHELL-VAR" , value_parser = parse_shell_name, verbatim_doc_comment) ]
66
67
remainder : Option < String > ,
67
68
68
- /// Stop option processing on first none-option
69
+ /// Stop option processing on first none-option.
69
70
#[ arg( short = 'p' , long = "posix" ) ]
70
71
posix : bool ,
71
72
@@ -87,18 +88,18 @@ struct CmdLineArgs {
87
88
#[ arg( short = 's' , long = "shell" , value_name = "SHELL" ) ]
88
89
shell : Option < String > ,
89
90
90
- /// Print help
91
+ /// Enable debug output to STDERR.
92
+ #[ arg( short = 'd' , long = "debug" ) ]
93
+ debug : bool ,
94
+
95
+ /// Print help.
91
96
#[ arg( long) ]
92
97
help : bool ,
93
98
94
- /// Print version
99
+ /// Print version.
95
100
#[ arg( long) ]
96
101
version : bool ,
97
102
98
- // Disabled for now
99
- // /// enable debug output to STDERR.
100
- // #[arg(short = 'd', long = "debug")]
101
- // debug: bool,
102
103
/// Shell script options
103
104
#[ arg( value_name = "SCRIPT-ARGS" ) ]
104
105
script_args : Vec < OsString > ,
@@ -555,12 +556,22 @@ fn parseargs(cmd_line_args: CmdLineArgs) -> ! {
555
556
} ) ;
556
557
}
557
558
559
+ if cmd_line_args. debug {
560
+ for oc in & opt_cfg_list {
561
+ eprintln ! ( "{:?}" , oc) ;
562
+ }
563
+ }
564
+
558
565
// Determine shell. Either from option, environment var or the default.
559
566
let shell = cmd_line_args
560
567
. shell
561
568
. clone ( )
562
569
. unwrap_or ( std:: env:: var ( PARSEARGS_SHELL_VAR ) . unwrap_or ( DEFAULT_SHELL . to_string ( ) ) ) ;
563
570
571
+ if cmd_line_args. debug {
572
+ eprintln ! ( "Shell: {}" , shell) ;
573
+ }
574
+
564
575
// get the shell templates
565
576
let shell_tmpl = shell_code:: get_shell_template ( shell. as_str ( ) ) ;
566
577
if shell_tmpl. is_none ( ) {
0 commit comments