@@ -90,19 +90,31 @@ impl Flags {
90
90
opts. optflag ( "h" , "help" , "print this help message" ) ;
91
91
92
92
let usage = |n, opts : & Options | -> ! {
93
- let subcommand = args. get ( 0 ) . map ( |s| & * * s) ;
94
- let brief = format ! ( "Usage: x.py <subcommand> [options] [<args>...]" ) ;
93
+ let subcommand_help = format ! ( "\
94
+ Usage: x.py <subcommand> [options] [<paths>...]
95
+
96
+ Subcommands:
97
+ build Compile either the compiler or libraries
98
+ test Build and run some test suites
99
+ bench Build and run some benchmarks
100
+ doc Build documentation
101
+ clean Clean out build directories
102
+ dist Build and/or install distribution artifacts
95
103
96
- println ! ( "{}" , opts. usage( & brief) ) ;
104
+ To learn more about a subcommand, run `./x.py <subcommand> -h`" ) ;
105
+
106
+ println ! ( "{}" , opts. usage( & subcommand_help) ) ;
107
+
108
+ let subcommand = args. get ( 0 ) . map ( |s| & * * s) ;
97
109
match subcommand {
98
110
Some ( "build" ) => {
99
111
println ! ( "\
100
112
Arguments:
101
- This subcommand accepts a number of positional arguments of directories to
102
- the crates and/or artifacts to compile. For example:
113
+ This subcommand accepts a number of paths to directories to the crates
114
+ and/or artifacts to compile. For example:
103
115
104
116
./x.py build src/libcore
105
- ./x.py build src/libproc_macro
117
+ ./x.py build src/libcore src/ libproc_macro
106
118
./x.py build src/libstd --stage 1
107
119
108
120
If no arguments are passed then the complete artifacts for that stage are
@@ -120,8 +132,8 @@ Arguments:
120
132
Some ( "test" ) => {
121
133
println ! ( "\
122
134
Arguments:
123
- This subcommand accepts a number of positional arguments of directories to
124
- tests that should be compiled and run. For example:
135
+ This subcommand accepts a number of paths to directories to tests that
136
+ should be compiled and run. For example:
125
137
126
138
./x.py test src/test/run-pass
127
139
./x.py test src/libstd --test-args hash_map
@@ -138,12 +150,12 @@ Arguments:
138
150
Some ( "doc" ) => {
139
151
println ! ( "\
140
152
Arguments:
141
- This subcommand accepts a number of positional arguments of directories of
142
- documentation to build. For example:
153
+ This subcommand accepts a number of paths to directories of documentation
154
+ to build. For example:
143
155
144
156
./x.py doc src/doc/book
145
157
./x.py doc src/doc/nomicon
146
- ./x.py doc src/libstd
158
+ ./x.py doc src/doc/book src/ libstd
147
159
148
160
If no arguments are passed then everything is documented:
149
161
@@ -155,14 +167,14 @@ Arguments:
155
167
_ => { }
156
168
}
157
169
170
+
158
171
if let Some ( subcommand) = subcommand {
159
172
if subcommand == "build" ||
160
173
subcommand == "test" ||
161
174
subcommand == "bench" ||
162
175
subcommand == "doc" ||
163
176
subcommand == "clean" ||
164
177
subcommand == "dist" {
165
- println ! ( "Available invocations:" ) ;
166
178
if args. iter ( ) . any ( |a| a == "-v" ) {
167
179
let flags = Flags :: parse ( & [ "build" . to_string ( ) ] ) ;
168
180
let mut config = Config :: default ( ) ;
@@ -171,26 +183,14 @@ Arguments:
171
183
metadata:: build ( & mut build) ;
172
184
step:: build_rules ( & build) . print_help ( subcommand) ;
173
185
} else {
174
- println ! ( " ... elided, run `./x.py {} -h -v` to see" ,
186
+ println ! ( "Run `./x.py {} -h -v` to see a list of available paths. " ,
175
187
subcommand) ;
176
188
}
177
189
178
190
println ! ( "" ) ;
179
191
}
180
192
}
181
193
182
- println ! ( "\
183
- Subcommands:
184
- build Compile either the compiler or libraries
185
- test Build and run some test suites
186
- bench Build and run some benchmarks
187
- doc Build documentation
188
- clean Clean out build directories
189
- dist Build and/or install distribution artifacts
190
-
191
- To learn more about a subcommand, run `./x.py <subcommand> -h`
192
- " ) ;
193
-
194
194
process:: exit ( n) ;
195
195
} ;
196
196
if args. len ( ) == 0 {
@@ -256,8 +256,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`
256
256
}
257
257
}
258
258
"--help" => usage ( 0 , & opts) ,
259
- cmd => {
260
- println ! ( "unknown subcommand: {}" , cmd) ;
259
+ _ => {
261
260
usage ( 1 , & opts) ;
262
261
}
263
262
} ;
0 commit comments