@@ -90,12 +90,11 @@ impl Flags {
90
90
opts. optflag ( "h" , "help" , "print this help message" ) ;
91
91
92
92
let usage = |n, opts : & Options | -> ! {
93
- let command = args. get ( 0 ) . map ( |s| & * * s) ;
94
- let brief = format ! ( "Usage: x.py {} [options] [<args>...]" ,
95
- command. unwrap_or( "<command>" ) ) ;
93
+ let subcommand = args. get ( 0 ) . map ( |s| & * * s) ;
94
+ let brief = format ! ( "Usage: x.py <subcommand> [options] [<args>...]" ) ;
96
95
97
96
println ! ( "{}" , opts. usage( & brief) ) ;
98
- match command {
97
+ match subcommand {
99
98
Some ( "build" ) => {
100
99
println ! ( "\
101
100
Arguments:
@@ -156,24 +155,24 @@ Arguments:
156
155
_ => { }
157
156
}
158
157
159
- if let Some ( command ) = command {
160
- if command == "build" ||
161
- command == "dist" ||
162
- command == "doc" ||
163
- command == "test" ||
164
- command == "bench" ||
165
- command == "clean" {
158
+ if let Some ( subcommand ) = subcommand {
159
+ if subcommand == "build" ||
160
+ subcommand == "dist" ||
161
+ subcommand == "doc" ||
162
+ subcommand == "test" ||
163
+ subcommand == "bench" ||
164
+ subcommand == "clean" {
166
165
println ! ( "Available invocations:" ) ;
167
166
if args. iter ( ) . any ( |a| a == "-v" ) {
168
167
let flags = Flags :: parse ( & [ "build" . to_string ( ) ] ) ;
169
168
let mut config = Config :: default ( ) ;
170
169
config. build = flags. build . clone ( ) ;
171
170
let mut build = Build :: new ( flags, config) ;
172
171
metadata:: build ( & mut build) ;
173
- step:: build_rules ( & build) . print_help ( command ) ;
172
+ step:: build_rules ( & build) . print_help ( subcommand ) ;
174
173
} else {
175
174
println ! ( " ... elided, run `./x.py {} -h -v` to see" ,
176
- command ) ;
175
+ subcommand ) ;
177
176
}
178
177
179
178
println ! ( "" ) ;
@@ -189,13 +188,13 @@ Subcommands:
189
188
clean Clean out build directories
190
189
dist Build and/or install distribution artifacts
191
190
192
- To learn more about a subcommand, run `./x.py <command > -h`
191
+ To learn more about a subcommand, run `./x.py <subcommand > -h`
193
192
" ) ;
194
193
195
194
process:: exit ( n) ;
196
195
} ;
197
196
if args. len ( ) == 0 {
198
- println ! ( "a command must be passed" ) ;
197
+ println ! ( "a subcommand must be passed" ) ;
199
198
usage ( 1 , & opts) ;
200
199
}
201
200
let parse = |opts : & Options | {
@@ -258,7 +257,7 @@ To learn more about a subcommand, run `./x.py <command> -h`
258
257
}
259
258
"--help" => usage ( 0 , & opts) ,
260
259
cmd => {
261
- println ! ( "unknown command : {}" , cmd) ;
260
+ println ! ( "unknown subcommand : {}" , cmd) ;
262
261
usage ( 1 , & opts) ;
263
262
}
264
263
} ;
0 commit comments