@@ -338,14 +338,21 @@ def visit_test(self, test: TestCase) -> None:
338338
339339
340340@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+ )
341348@click .option (
342349 "--read-from-stdin" ,
343350 is_flag = True ,
344351 help = "Read file contents from stdin. This is an internal option." ,
345352 hidden = show_hidden_arguments (),
346353)
347354@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 :
349356 """\
350357 Commands to discover informations about the current project.
351358
@@ -356,6 +363,7 @@ def discover(app: Application, read_from_stdin: bool) -> None:
356363 robotcode --profile regression discover tests
357364 ```
358365 """
366+ app .show_diagnostics = show_diagnostics or app .config .log_enabled
359367 if read_from_stdin :
360368 global _stdin_data
361369 _stdin_data = from_json (sys .stdin .buffer .read (), Dict [str , str ], strict = True )
@@ -422,7 +430,6 @@ def add_diagnostic(
422430
423431def handle_options (
424432 app : Application ,
425- diagnostics : bool ,
426433 by_longname : Tuple [str , ...],
427434 exclude_by_longname : Tuple [str , ...],
428435 robot_options_and_args : Tuple [str , ...],
@@ -447,7 +454,7 @@ def handle_options(
447454
448455 settings = RobotSettings (options )
449456
450- if diagnostics :
457+ if app . show_diagnostics :
451458 LOGGER .register_console_logger (** settings .console_output_config )
452459 else :
453460 LOGGER .unregister_console_logger ()
@@ -505,17 +512,6 @@ def handle_options(
505512 raise UnknownError ("Unexpected error happened." )
506513
507514
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-
519515@discover .command (
520516 context_settings = {
521517 "allow_extra_args" : True ,
@@ -524,12 +520,10 @@ def handle_options(
524520 add_help_option = True ,
525521 epilog = 'Use "-- --help" to see `robot` help.' ,
526522)
527- @add_options (* DIAGOSTICS_OPTIONS )
528523@add_options (* ROBOT_OPTIONS )
529524@pass_application
530525def all (
531526 app : Application ,
532- show_diagnostics : bool ,
533527 by_longname : Tuple [str , ...],
534528 exclude_by_longname : Tuple [str , ...],
535529 robot_options_and_args : Tuple [str , ...],
@@ -549,9 +543,7 @@ def all(
549543 ```
550544 """
551545
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 )
555547
556548 if collector .all .children :
557549 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]:
614606 show_default = True ,
615607 help = "Show full paths instead of releative." ,
616608)
617- @add_options (* DIAGOSTICS_OPTIONS )
618609@add_options (* ROBOT_OPTIONS )
619610@pass_application
620611def tests (
621612 app : Application ,
622- show_diagnostics : bool ,
623613 full_paths : bool ,
624614 show_tags : bool ,
625615 by_longname : Tuple [str , ...],
@@ -641,9 +631,7 @@ def tests(
641631 ```
642632 """
643633
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 )
647635
648636 if collector .all .children :
649637 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]:
674662 add_help_option = True ,
675663 epilog = 'Use "-- --help" to see `robot` help.' ,
676664)
677- @add_options (* DIAGOSTICS_OPTIONS )
678665@add_options (* ROBOT_OPTIONS )
679666@pass_application
680667def suites (
681668 app : Application ,
682- show_diagnostics : bool ,
683669 by_longname : Tuple [str , ...],
684670 exclude_by_longname : Tuple [str , ...],
685671 robot_options_and_args : Tuple [str , ...],
@@ -699,9 +685,7 @@ def suites(
699685 ```
700686 """
701687
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 )
705689
706690 if collector .all .children :
707691 if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
@@ -751,12 +735,10 @@ class TagsResult:
751735 show_default = True ,
752736 help = "Show full paths instead of releative." ,
753737)
754- @add_options (* DIAGOSTICS_OPTIONS )
755738@add_options (* ROBOT_OPTIONS )
756739@pass_application
757740def tags (
758741 app : Application ,
759- show_diagnostics : bool ,
760742 normalized : bool ,
761743 show_tests : bool ,
762744 full_paths : bool ,
@@ -780,9 +762,7 @@ def tags(
780762 ```
781763 """
782764
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 )
786766
787767 if collector .all .children :
788768 if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
0 commit comments