@@ -415,6 +415,7 @@ def add_diagnostic(
415
415
416
416
def handle_options (
417
417
app : Application ,
418
+ diagnostics : bool ,
418
419
by_longname : Tuple [str , ...],
419
420
exclude_by_longname : Tuple [str , ...],
420
421
robot_options_and_args : Tuple [str , ...],
@@ -439,7 +440,10 @@ def handle_options(
439
440
440
441
settings = RobotSettings (options )
441
442
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 ()
443
447
444
448
diagnostics_logger = DiagnosticsLogger ()
445
449
LOGGER .register_logger (diagnostics_logger )
@@ -494,6 +498,16 @@ def handle_options(
494
498
raise UnknownError ("Unexpected error happened." )
495
499
496
500
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
+
497
511
@discover .command (
498
512
context_settings = {
499
513
"allow_extra_args" : True ,
@@ -502,10 +516,12 @@ def handle_options(
502
516
add_help_option = True ,
503
517
epilog = 'Use "-- --help" to see `robot` help.' ,
504
518
)
519
+ @add_options (* DIAGOSTICS_OPTIONS )
505
520
@add_options (* ROBOT_OPTIONS )
506
521
@pass_application
507
522
def all (
508
523
app : Application ,
524
+ show_diagnostics : bool ,
509
525
by_longname : Tuple [str , ...],
510
526
exclude_by_longname : Tuple [str , ...],
511
527
robot_options_and_args : Tuple [str , ...],
@@ -525,7 +541,9 @@ def all(
525
541
```
526
542
"""
527
543
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
+ )
529
547
530
548
if collector .all .children :
531
549
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]:
574
592
add_help_option = True ,
575
593
epilog = 'Use "-- --help" to see `robot` help.' ,
576
594
)
595
+ @add_options (* DIAGOSTICS_OPTIONS )
577
596
@add_options (* ROBOT_OPTIONS )
578
597
@pass_application
579
598
def tests (
580
599
app : Application ,
600
+ show_diagnostics : bool ,
581
601
by_longname : Tuple [str , ...],
582
602
exclude_by_longname : Tuple [str , ...],
583
603
robot_options_and_args : Tuple [str , ...],
@@ -597,7 +617,9 @@ def tests(
597
617
```
598
618
"""
599
619
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
+ )
601
623
602
624
if collector .all .children :
603
625
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]:
621
643
add_help_option = True ,
622
644
epilog = 'Use "-- --help" to see `robot` help.' ,
623
645
)
646
+ @add_options (* DIAGOSTICS_OPTIONS )
624
647
@add_options (* ROBOT_OPTIONS )
625
648
@pass_application
626
649
def suites (
627
650
app : Application ,
651
+ show_diagnostics : bool ,
628
652
by_longname : Tuple [str , ...],
629
653
exclude_by_longname : Tuple [str , ...],
630
654
robot_options_and_args : Tuple [str , ...],
@@ -644,7 +668,9 @@ def suites(
644
668
```
645
669
"""
646
670
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
+ )
648
674
649
675
if collector .all .children :
650
676
if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
@@ -679,10 +705,12 @@ class TagsResult:
679
705
default = True ,
680
706
help = "Whether or not normalized tags are shown." ,
681
707
)
708
+ @add_options (* DIAGOSTICS_OPTIONS )
682
709
@add_options (* ROBOT_OPTIONS )
683
710
@pass_application
684
711
def tags (
685
712
app : Application ,
713
+ show_diagnostics : bool ,
686
714
normalized : bool ,
687
715
by_longname : Tuple [str , ...],
688
716
exclude_by_longname : Tuple [str , ...],
@@ -704,7 +732,9 @@ def tags(
704
732
```
705
733
"""
706
734
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
+ )
708
738
709
739
if collector .all .children :
710
740
if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
0 commit comments