@@ -55,15 +55,11 @@ struct Args {
5555 #[ clap( long) ]
5656 take : Option < String > ,
5757
58- /// If set, lintrunner will render lint messages as JSON, according to the
59- /// LintMessage spec.
60- #[ clap( long) ]
61- json : bool ,
62-
63- /// If set, lintrunner will render lint messages in a compact format, one
64- /// line per message
65- #[ clap( long, conflicts_with = "json" ) ]
66- oneline : bool ,
58+ /// With 'default' show lint issues in human-readable format, for interactive use.
59+ /// With 'json', show lint issues as machine-readable JSON (one per line)
60+ /// With 'oneline', show lint issues in compact format (one per line)
61+ #[ clap( long, arg_enum, default_value_t = RenderOpt :: Default ) ]
62+ output : RenderOpt ,
6763
6864 #[ clap( subcommand) ]
6965 cmd : Option < SubCommand > ,
@@ -94,7 +90,7 @@ fn do_main() -> Result<i32> {
9490 console:: set_colors_enabled ( true ) ;
9591 console:: set_colors_enabled_stderr ( true ) ;
9692 }
97- let log_level = match ( args. verbose , args. json ) {
93+ let log_level = match ( args. verbose , args. output != RenderOpt :: Default ) {
9894 // Default
9995 ( 0 , false ) => log:: LevelFilter :: Info ,
10096 // If just json is asked for, suppress most output except hard errors.
@@ -126,7 +122,7 @@ fn do_main() -> Result<i32> {
126122
127123 let linters = get_linters_from_config ( & config_path, skipped_linters, taken_linters) ?;
128124
129- let enable_spinners = args. verbose == 0 && ! args. json ;
125+ let enable_spinners = args. verbose == 0 && args. output == RenderOpt :: Default ;
130126
131127 let paths_to_lint = if let Some ( paths_file) = args. paths_from {
132128 let path_file = AbsPath :: try_from ( & paths_file)
@@ -148,14 +144,6 @@ fn do_main() -> Result<i32> {
148144 RevisionOpt :: Head
149145 } ;
150146
151- let render_opt = if args. json {
152- RenderOpt :: Json
153- } else if args. oneline {
154- RenderOpt :: Oneline
155- } else {
156- RenderOpt :: Default
157- } ;
158-
159147 match args. cmd {
160148 Some ( SubCommand :: Init { dry_run } ) => {
161149 // Just run initialization commands, don't actually lint.
@@ -167,7 +155,7 @@ fn do_main() -> Result<i32> {
167155 linters,
168156 paths_to_lint,
169157 args. apply_patches ,
170- render_opt ,
158+ args . output ,
171159 enable_spinners,
172160 revision_opt,
173161 )
0 commit comments