@@ -190,6 +190,7 @@ class TestItem:
190
190
longname : str
191
191
uri : Optional [DocumentUri ] = None
192
192
rel_source : Optional [str ] = None
193
+ source : Optional [str ] = None
193
194
needs_parse_include : bool = False
194
195
children : Optional [List ["TestItem" ]] = None
195
196
description : Optional [str ] = None
@@ -260,6 +261,7 @@ def visit_suite(self, suite: TestSuite) -> None:
260
261
name = suite .name ,
261
262
longname = suite .longname ,
262
263
uri = str (Uri .from_path (Path (suite .source ).resolve ())) if suite .source else None ,
264
+ source = str (suite .source ),
263
265
rel_source = get_rel_source (suite .source ),
264
266
range = Range (
265
267
start = Position (line = 0 , character = 0 ),
@@ -311,6 +313,7 @@ def visit_test(self, test: TestCase) -> None:
311
313
name = test .name ,
312
314
longname = test .longname ,
313
315
uri = str (Uri .from_path (Path (test .source ).resolve ())) if test .source else None ,
316
+ source = str (test .source ),
314
317
rel_source = get_rel_source (test .source ),
315
318
range = Range (
316
319
start = Position (line = test .lineno - 1 , character = 0 ),
@@ -504,6 +507,7 @@ def handle_options(
504
507
"--diagnostics / --no-diagnostics" ,
505
508
"show_diagnostics" ,
506
509
default = True ,
510
+ show_default = True ,
507
511
help = "Display `robot` parsing errors and warning that occur during discovering." ,
508
512
)
509
513
}
@@ -593,12 +597,28 @@ def print(item: TestItem, indent: int = 0) -> Iterable[str]:
593
597
add_help_option = True ,
594
598
epilog = 'Use "-- --help" to see `robot` help.' ,
595
599
)
600
+ @click .option (
601
+ "--tags / --no-tags" ,
602
+ "show_tags" ,
603
+ default = False ,
604
+ show_default = True ,
605
+ help = "Show the tags that are present." ,
606
+ )
607
+ @click .option (
608
+ "--full-paths / --no-full-paths" ,
609
+ "full_paths" ,
610
+ default = False ,
611
+ show_default = True ,
612
+ help = "Show full paths instead of releative." ,
613
+ )
596
614
@add_options (* DIAGOSTICS_OPTIONS )
597
615
@add_options (* ROBOT_OPTIONS )
598
616
@pass_application
599
617
def tests (
600
618
app : Application ,
601
619
show_diagnostics : bool ,
620
+ full_paths : bool ,
621
+ show_tags : bool ,
602
622
by_longname : Tuple [str , ...],
603
623
exclude_by_longname : Tuple [str , ...],
604
624
robot_options_and_args : Tuple [str , ...],
@@ -627,7 +647,14 @@ def tests(
627
647
628
648
def print (items : List [TestItem ]) -> Iterable [str ]:
629
649
for item in items :
630
- yield f"{ item .longname } { os .linesep } "
650
+ yield click .style (f"{ item .longname } " , bold = True , fg = "green" if show_tags else None )
651
+ yield click .style (
652
+ f" ({ item .source if full_paths else item .rel_source } "
653
+ f":{ item .range .start .line + 1 if item .range is not None else 1 } ){ os .linesep } "
654
+ )
655
+ if show_tags and item .tags :
656
+ yield click .style (" Tags:" , bold = True )
657
+ yield f" { ', ' . join (normalize (str (tag ), ignore = '_' ) for tag in item .tags )} { os .linesep } "
631
658
632
659
if collector .tests :
633
660
app .echo_via_pager (print (collector .tests ))
@@ -704,15 +731,32 @@ class TagsResult:
704
731
"--normalized / --not-normalized" ,
705
732
"normalized" ,
706
733
default = True ,
734
+ show_default = True ,
707
735
help = "Whether or not normalized tags are shown." ,
708
736
)
737
+ @click .option (
738
+ "--tests / --no-tests" ,
739
+ "show_tests" ,
740
+ default = False ,
741
+ show_default = True ,
742
+ help = "Show tests where the tag is present." ,
743
+ )
744
+ @click .option (
745
+ "--full-paths / --no-full-paths" ,
746
+ "full_paths" ,
747
+ default = False ,
748
+ show_default = True ,
749
+ help = "Show full paths instead of releative." ,
750
+ )
709
751
@add_options (* DIAGOSTICS_OPTIONS )
710
752
@add_options (* ROBOT_OPTIONS )
711
753
@pass_application
712
754
def tags (
713
755
app : Application ,
714
756
show_diagnostics : bool ,
715
757
normalized : bool ,
758
+ show_tests : bool ,
759
+ full_paths : bool ,
716
760
by_longname : Tuple [str , ...],
717
761
exclude_by_longname : Tuple [str , ...],
718
762
robot_options_and_args : Tuple [str , ...],
@@ -729,7 +773,7 @@ def tags(
729
773
robotcode discover tags
730
774
robotcode --profile regression discover tags
731
775
732
- robotcode --profile regression discover tags -i wip
776
+ robotcode --profile regression discover tags --tests - i wip
733
777
```
734
778
"""
735
779
@@ -742,9 +786,13 @@ def tags(
742
786
743
787
def print (tags : Dict [str , List [TestItem ]]) -> Iterable [str ]:
744
788
for tag , items in tags .items ():
745
- yield f"{ tag } { os .linesep } "
746
- # for t in items:
747
- # yield f" {t.longname}{os.linesep}"
789
+ yield click .style (f"{ tag } { os .linesep } " , bold = show_tests , fg = "green" if show_tests else None )
790
+ if show_tests :
791
+ for t in items :
792
+ yield click .style (f" { t .longname } " , bold = True ) + click .style (
793
+ f" ({ t .source if full_paths else t .rel_source } "
794
+ f":{ t .range .start .line + 1 if t .range is not None else 1 } ){ os .linesep } "
795
+ )
748
796
749
797
if collector .normalized_tags :
750
798
app .echo_via_pager (print (collector .normalized_tags if normalized else collector .tags ))
0 commit comments