@@ -175,11 +175,25 @@ pub struct PingGoalsArgs {
175175
176176/// Helper function to parse CLI arguments without any colored help or error output.
177177pub 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+
178190 // Add a fake first argument, which is expected by clap
179191 let input = std:: iter:: once ( "triagebot" ) . chain ( input) ;
180192
181193 let matches = T :: command ( )
182194 . color ( ColorChoice :: Never )
195+ // Allow title-case subcommands
196+ . mut_subcommands ( allow_title_case)
183197 . try_get_matches_from ( input) ?;
184198 let value = T :: from_arg_matches ( & matches) ?;
185199 Ok ( value)
@@ -234,6 +248,11 @@ mod tests {
234248 assert_eq ! ( parse_chat( & [ "whoami" ] ) , ChatCommand :: Whoami ) ;
235249 }
236250
251+ #[ test]
252+ fn whoami_uppercased_command ( ) {
253+ assert_eq ! ( parse_chat( & [ "Whoami" ] ) , ChatCommand :: Whoami ) ;
254+ }
255+
237256 #[ test]
238257 fn lookup_command ( ) {
239258 assert_eq ! (
@@ -259,6 +278,14 @@ mod tests {
259278 ) ;
260279 }
261280
281+ #[ test]
282+ fn work_uppercased_command ( ) {
283+ assert_eq ! (
284+ parse_chat( & [ "Work" , "Show" ] ) ,
285+ ChatCommand :: Work ( WorkqueueCmd :: Show )
286+ ) ;
287+ }
288+
262289 #[ test]
263290 fn end_meeting_command ( ) {
264291 assert_eq ! ( parse_stream( & [ "end-meeting" ] ) , StreamCommand :: EndMeeting ) ;
0 commit comments