@@ -175,11 +175,25 @@ pub struct PingGoalsArgs {
175
175
176
176
/// Helper function to parse CLI arguments without any colored help or error output.
177
177
pub fn parse_cli < ' a , T : Parser , I : Iterator < Item = & ' a str > > ( input : I ) -> anyhow:: Result < T > {
178
+ fn allow_title_case ( sub : clap:: Command ) -> clap:: Command {
179
+ let name = sub. get_name ( ) ;
180
+ let alias = name
181
+ . chars ( )
182
+ . enumerate ( )
183
+ . map ( |( i, c) | if i == 0 { c. to_ascii_uppercase ( ) } else { c } )
184
+ . collect :: < String > ( ) ;
185
+ sub. alias ( alias)
186
+ // Recursively allow title-case subcommands
187
+ . mut_subcommands ( allow_title_case)
188
+ }
189
+
178
190
// Add a fake first argument, which is expected by clap
179
191
let input = std:: iter:: once ( "triagebot" ) . chain ( input) ;
180
192
181
193
let matches = T :: command ( )
182
194
. color ( ColorChoice :: Never )
195
+ // Allow title-case subcommands
196
+ . mut_subcommands ( allow_title_case)
183
197
. try_get_matches_from ( input) ?;
184
198
let value = T :: from_arg_matches ( & matches) ?;
185
199
Ok ( value)
@@ -234,6 +248,11 @@ mod tests {
234
248
assert_eq ! ( parse_chat( & [ "whoami" ] ) , ChatCommand :: Whoami ) ;
235
249
}
236
250
251
+ #[ test]
252
+ fn whoami_uppercased_command ( ) {
253
+ assert_eq ! ( parse_chat( & [ "Whoami" ] ) , ChatCommand :: Whoami ) ;
254
+ }
255
+
237
256
#[ test]
238
257
fn lookup_command ( ) {
239
258
assert_eq ! (
@@ -259,6 +278,14 @@ mod tests {
259
278
) ;
260
279
}
261
280
281
+ #[ test]
282
+ fn work_uppercased_command ( ) {
283
+ assert_eq ! (
284
+ parse_chat( & [ "Work" , "Show" ] ) ,
285
+ ChatCommand :: Work ( WorkqueueCmd :: Show )
286
+ ) ;
287
+ }
288
+
262
289
#[ test]
263
290
fn end_meeting_command ( ) {
264
291
assert_eq ! ( parse_stream( & [ "end-meeting" ] ) , StreamCommand :: EndMeeting ) ;
0 commit comments