@@ -43,7 +43,12 @@ pub fn main(config: &mut Config) -> CliResult {
43
43
}
44
44
} ;
45
45
46
- if args. value_of ( "unstable-features" ) == Some ( "help" ) {
46
+ // Global args need to be extracted before expanding aliases because the
47
+ // clap code for extracting a subcommand discards global options
48
+ // (appearing before the subcommand).
49
+ let ( expanded_args, global_args) = expand_aliases ( config, args, vec ! [ ] ) ?;
50
+
51
+ if expanded_args. value_of ( "unstable-features" ) == Some ( "help" ) {
47
52
let options = CliUnstable :: help ( ) ;
48
53
let non_hidden_options: Vec < ( String , String ) > = options
49
54
. iter ( )
@@ -95,20 +100,20 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'",
95
100
return Ok ( ( ) ) ;
96
101
}
97
102
98
- let is_verbose = args . occurrences_of ( "verbose" ) > 0 ;
99
- if args . is_present ( "version" ) {
103
+ let is_verbose = expanded_args . occurrences_of ( "verbose" ) > 0 ;
104
+ if expanded_args . is_present ( "version" ) {
100
105
let version = get_version_string ( is_verbose) ;
101
106
drop_print ! ( config, "{}" , version) ;
102
107
return Ok ( ( ) ) ;
103
108
}
104
109
105
- if let Some ( code) = args . value_of ( "explain" ) {
110
+ if let Some ( code) = expanded_args . value_of ( "explain" ) {
106
111
let mut procss = config. load_global_rustc ( None ) ?. process ( ) ;
107
112
procss. arg ( "--explain" ) . arg ( code) . exec ( ) ?;
108
113
return Ok ( ( ) ) ;
109
114
}
110
115
111
- if args . is_present ( "list" ) {
116
+ if expanded_args . is_present ( "list" ) {
112
117
drop_println ! ( config, "Installed Commands:" ) ;
113
118
for ( name, command) in list_commands ( config) {
114
119
let known_external_desc = KNOWN_EXTERNAL_COMMAND_DESCRIPTIONS . get ( name. as_str ( ) ) ;
@@ -140,10 +145,6 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'",
140
145
return Ok ( ( ) ) ;
141
146
}
142
147
143
- // Global args need to be extracted before expanding aliases because the
144
- // clap code for extracting a subcommand discards global options
145
- // (appearing before the subcommand).
146
- let ( expanded_args, global_args) = expand_aliases ( config, args, vec ! [ ] ) ?;
147
148
let ( cmd, subcommand_args) = match expanded_args. subcommand ( ) {
148
149
( cmd, Some ( args) ) => ( cmd, args) ,
149
150
_ => {
0 commit comments