@@ -437,6 +437,7 @@ fn parse_issue_comment_args(
437437) -> Result < ParseOutcome < IssueCommentRequest > , CommandError > {
438438 map_parsed ( parse_matches ( issue_comment_command ( ) , args) , |matches| {
439439 let output = output_format ( & matches) ;
440+ validate_json_field_selection ( & output, "issue comment" , & [ ] ) ?;
440441 let repo = last_value ( & matches, "repo" ) ;
441442 let body_values = values ( & matches, "body" ) ;
442443 let body_file_values = values ( & matches, "body_file" ) ;
@@ -488,6 +489,7 @@ fn parse_issue_create_args(
488489) -> Result < ParseOutcome < IssueCreateRequest > , CommandError > {
489490 map_parsed ( parse_matches ( issue_create_command ( ) , args) , |matches| {
490491 let output = output_format ( & matches) ;
492+ validate_json_field_selection ( & output, "issue create" , & [ ] ) ?;
491493 let repo = last_value ( & matches, "repo" ) ;
492494 let title = last_value ( & matches, "title" ) ;
493495 let body_values = values ( & matches, "body" ) ;
@@ -986,24 +988,35 @@ fn flag_count(matches: &ArgMatches, id: &str) -> usize {
986988}
987989
988990fn render_help ( mut command : Command ) -> CommandOutcome {
991+ let supports_json_field_selection = help_command_supports_json_field_selection ( & command) ;
989992 let mut buffer = Vec :: new ( ) ;
990993 command
991994 . write_long_help ( & mut buffer)
992995 . expect ( "writing clap help should succeed" ) ;
993996
994- CommandOutcome :: text (
995- EXIT_OK ,
996- String :: from_utf8 ( buffer)
997- . expect ( "clap help should be utf-8" )
998- . trim_end ( )
999- . to_string ( ) ,
1000- )
997+ let body = String :: from_utf8 ( buffer)
998+ . expect ( "clap help should be utf-8" )
999+ . trim_end ( )
1000+ . to_string ( ) ;
1001+ let body = if supports_json_field_selection {
1002+ body
1003+ } else {
1004+ body. replace ( "--json [<FIELDS>]" , "--json" )
1005+ } ;
1006+
1007+ CommandOutcome :: text ( EXIT_OK , body)
10011008}
10021009
10031010fn render_version ( ) -> CommandOutcome {
10041011 CommandOutcome :: text ( EXIT_OK , format ! ( "gitee {}" , env!( "CARGO_PKG_VERSION" ) ) )
10051012}
10061013
1014+ fn help_command_supports_json_field_selection ( command : & Command ) -> bool {
1015+ let path = command. get_bin_name ( ) . unwrap_or ( command. get_name ( ) ) ;
1016+ let path = path. strip_prefix ( "gitee " ) . unwrap_or ( path) ;
1017+ json_field_selection_for_help ( path) . is_some ( )
1018+ }
1019+
10071020fn is_help_flag ( arg : & str ) -> bool {
10081021 matches ! ( arg, "--help" | "-h" )
10091022}
0 commit comments