@@ -338,14 +338,21 @@ def visit_test(self, test: TestCase) -> None:
338
338
339
339
340
340
@click .group (invoke_without_command = False )
341
+ @click .option (
342
+ "--diagnostics / --no-diagnostics" ,
343
+ "show_diagnostics" ,
344
+ default = True ,
345
+ show_default = True ,
346
+ help = "Display `robot` parsing errors and warning that occur during discovering." ,
347
+ )
341
348
@click .option (
342
349
"--read-from-stdin" ,
343
350
is_flag = True ,
344
351
help = "Read file contents from stdin. This is an internal option." ,
345
352
hidden = show_hidden_arguments (),
346
353
)
347
354
@pass_application
348
- def discover (app : Application , read_from_stdin : bool ) -> None :
355
+ def discover (app : Application , show_diagnostics : bool , read_from_stdin : bool ) -> None :
349
356
"""\
350
357
Commands to discover informations about the current project.
351
358
@@ -356,6 +363,7 @@ def discover(app: Application, read_from_stdin: bool) -> None:
356
363
robotcode --profile regression discover tests
357
364
```
358
365
"""
366
+ app .show_diagnostics = show_diagnostics or app .config .log_enabled
359
367
if read_from_stdin :
360
368
global _stdin_data
361
369
_stdin_data = from_json (sys .stdin .buffer .read (), Dict [str , str ], strict = True )
@@ -422,7 +430,6 @@ def add_diagnostic(
422
430
423
431
def handle_options (
424
432
app : Application ,
425
- diagnostics : bool ,
426
433
by_longname : Tuple [str , ...],
427
434
exclude_by_longname : Tuple [str , ...],
428
435
robot_options_and_args : Tuple [str , ...],
@@ -447,7 +454,7 @@ def handle_options(
447
454
448
455
settings = RobotSettings (options )
449
456
450
- if diagnostics :
457
+ if app . show_diagnostics :
451
458
LOGGER .register_console_logger (** settings .console_output_config )
452
459
else :
453
460
LOGGER .unregister_console_logger ()
@@ -505,17 +512,6 @@ def handle_options(
505
512
raise UnknownError ("Unexpected error happened." )
506
513
507
514
508
- DIAGOSTICS_OPTIONS = {
509
- click .option (
510
- "--diagnostics / --no-diagnostics" ,
511
- "show_diagnostics" ,
512
- default = True ,
513
- show_default = True ,
514
- help = "Display `robot` parsing errors and warning that occur during discovering." ,
515
- )
516
- }
517
-
518
-
519
515
@discover .command (
520
516
context_settings = {
521
517
"allow_extra_args" : True ,
@@ -524,12 +520,10 @@ def handle_options(
524
520
add_help_option = True ,
525
521
epilog = 'Use "-- --help" to see `robot` help.' ,
526
522
)
527
- @add_options (* DIAGOSTICS_OPTIONS )
528
523
@add_options (* ROBOT_OPTIONS )
529
524
@pass_application
530
525
def all (
531
526
app : Application ,
532
- show_diagnostics : bool ,
533
527
by_longname : Tuple [str , ...],
534
528
exclude_by_longname : Tuple [str , ...],
535
529
robot_options_and_args : Tuple [str , ...],
@@ -549,9 +543,7 @@ def all(
549
543
```
550
544
"""
551
545
552
- suite , collector , diagnostics = handle_options (
553
- app , show_diagnostics , by_longname , exclude_by_longname , robot_options_and_args
554
- )
546
+ suite , collector , diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
555
547
556
548
if collector .all .children :
557
549
if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
@@ -614,12 +606,10 @@ def print(item: TestItem, indent: int = 0) -> Iterable[str]:
614
606
show_default = True ,
615
607
help = "Show full paths instead of releative." ,
616
608
)
617
- @add_options (* DIAGOSTICS_OPTIONS )
618
609
@add_options (* ROBOT_OPTIONS )
619
610
@pass_application
620
611
def tests (
621
612
app : Application ,
622
- show_diagnostics : bool ,
623
613
full_paths : bool ,
624
614
show_tags : bool ,
625
615
by_longname : Tuple [str , ...],
@@ -641,9 +631,7 @@ def tests(
641
631
```
642
632
"""
643
633
644
- suite , collector , diagnostics = handle_options (
645
- app , show_diagnostics , by_longname , exclude_by_longname , robot_options_and_args
646
- )
634
+ suite , collector , diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
647
635
648
636
if collector .all .children :
649
637
if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
@@ -674,12 +662,10 @@ def print(items: List[TestItem]) -> Iterable[str]:
674
662
add_help_option = True ,
675
663
epilog = 'Use "-- --help" to see `robot` help.' ,
676
664
)
677
- @add_options (* DIAGOSTICS_OPTIONS )
678
665
@add_options (* ROBOT_OPTIONS )
679
666
@pass_application
680
667
def suites (
681
668
app : Application ,
682
- show_diagnostics : bool ,
683
669
by_longname : Tuple [str , ...],
684
670
exclude_by_longname : Tuple [str , ...],
685
671
robot_options_and_args : Tuple [str , ...],
@@ -699,9 +685,7 @@ def suites(
699
685
```
700
686
"""
701
687
702
- suite , collector , diagnostics = handle_options (
703
- app , show_diagnostics , by_longname , exclude_by_longname , robot_options_and_args
704
- )
688
+ suite , collector , diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
705
689
706
690
if collector .all .children :
707
691
if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
@@ -751,12 +735,10 @@ class TagsResult:
751
735
show_default = True ,
752
736
help = "Show full paths instead of releative." ,
753
737
)
754
- @add_options (* DIAGOSTICS_OPTIONS )
755
738
@add_options (* ROBOT_OPTIONS )
756
739
@pass_application
757
740
def tags (
758
741
app : Application ,
759
- show_diagnostics : bool ,
760
742
normalized : bool ,
761
743
show_tests : bool ,
762
744
full_paths : bool ,
@@ -780,9 +762,7 @@ def tags(
780
762
```
781
763
"""
782
764
783
- _suite , collector , _diagnostics = handle_options (
784
- app , show_diagnostics , by_longname , exclude_by_longname , robot_options_and_args
785
- )
765
+ _suite , collector , _diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
786
766
787
767
if collector .all .children :
788
768
if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
0 commit comments