@@ -415,6 +415,7 @@ def add_diagnostic(
415415
416416def handle_options (
417417 app : Application ,
418+ diagnostics : bool ,
418419 by_longname : Tuple [str , ...],
419420 exclude_by_longname : Tuple [str , ...],
420421 robot_options_and_args : Tuple [str , ...],
@@ -439,7 +440,10 @@ def handle_options(
439440
440441 settings = RobotSettings (options )
441442
442- LOGGER .register_console_logger (** settings .console_output_config )
443+ if diagnostics :
444+ LOGGER .register_console_logger (** settings .console_output_config )
445+ else :
446+ LOGGER .unregister_console_logger ()
443447
444448 diagnostics_logger = DiagnosticsLogger ()
445449 LOGGER .register_logger (diagnostics_logger )
@@ -494,6 +498,16 @@ def handle_options(
494498 raise UnknownError ("Unexpected error happened." )
495499
496500
501+ DIAGOSTICS_OPTIONS = {
502+ click .option (
503+ "--diagnostics / --no-diagnostics" ,
504+ "show_diagnostics" ,
505+ default = True ,
506+ help = "Display `robot` parsing errors and warning that occur during discovering." ,
507+ )
508+ }
509+
510+
497511@discover .command (
498512 context_settings = {
499513 "allow_extra_args" : True ,
@@ -502,10 +516,12 @@ def handle_options(
502516 add_help_option = True ,
503517 epilog = 'Use "-- --help" to see `robot` help.' ,
504518)
519+ @add_options (* DIAGOSTICS_OPTIONS )
505520@add_options (* ROBOT_OPTIONS )
506521@pass_application
507522def all (
508523 app : Application ,
524+ show_diagnostics : bool ,
509525 by_longname : Tuple [str , ...],
510526 exclude_by_longname : Tuple [str , ...],
511527 robot_options_and_args : Tuple [str , ...],
@@ -525,7 +541,9 @@ def all(
525541 ```
526542 """
527543
528- suite , collector , diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
544+ suite , collector , diagnostics = handle_options (
545+ app , show_diagnostics , by_longname , exclude_by_longname , robot_options_and_args
546+ )
529547
530548 if collector .all .children :
531549 if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
@@ -574,10 +592,12 @@ def print(item: TestItem, indent: int = 0) -> Iterable[str]:
574592 add_help_option = True ,
575593 epilog = 'Use "-- --help" to see `robot` help.' ,
576594)
595+ @add_options (* DIAGOSTICS_OPTIONS )
577596@add_options (* ROBOT_OPTIONS )
578597@pass_application
579598def tests (
580599 app : Application ,
600+ show_diagnostics : bool ,
581601 by_longname : Tuple [str , ...],
582602 exclude_by_longname : Tuple [str , ...],
583603 robot_options_and_args : Tuple [str , ...],
@@ -597,7 +617,9 @@ def tests(
597617 ```
598618 """
599619
600- suite , collector , diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
620+ suite , collector , diagnostics = handle_options (
621+ app , show_diagnostics , by_longname , exclude_by_longname , robot_options_and_args
622+ )
601623
602624 if collector .all .children :
603625 if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
@@ -621,10 +643,12 @@ def print(items: List[TestItem]) -> Iterable[str]:
621643 add_help_option = True ,
622644 epilog = 'Use "-- --help" to see `robot` help.' ,
623645)
646+ @add_options (* DIAGOSTICS_OPTIONS )
624647@add_options (* ROBOT_OPTIONS )
625648@pass_application
626649def suites (
627650 app : Application ,
651+ show_diagnostics : bool ,
628652 by_longname : Tuple [str , ...],
629653 exclude_by_longname : Tuple [str , ...],
630654 robot_options_and_args : Tuple [str , ...],
@@ -644,7 +668,9 @@ def suites(
644668 ```
645669 """
646670
647- suite , collector , diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
671+ suite , collector , diagnostics = handle_options (
672+ app , show_diagnostics , by_longname , exclude_by_longname , robot_options_and_args
673+ )
648674
649675 if collector .all .children :
650676 if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
@@ -679,10 +705,12 @@ class TagsResult:
679705 default = True ,
680706 help = "Whether or not normalized tags are shown." ,
681707)
708+ @add_options (* DIAGOSTICS_OPTIONS )
682709@add_options (* ROBOT_OPTIONS )
683710@pass_application
684711def tags (
685712 app : Application ,
713+ show_diagnostics : bool ,
686714 normalized : bool ,
687715 by_longname : Tuple [str , ...],
688716 exclude_by_longname : Tuple [str , ...],
@@ -704,7 +732,9 @@ def tags(
704732 ```
705733 """
706734
707- _suite , collector , _diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
735+ _suite , collector , _diagnostics = handle_options (
736+ app , show_diagnostics , by_longname , exclude_by_longname , robot_options_and_args
737+ )
708738
709739 if collector .all .children :
710740 if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
0 commit comments