@@ -546,10 +546,26 @@ def handle_options(
546
546
add_help_option = True ,
547
547
epilog = 'Use "-- --help" to see `robot` help.' ,
548
548
)
549
+ @click .option (
550
+ "--tags / --no-tags" ,
551
+ "show_tags" ,
552
+ default = False ,
553
+ show_default = True ,
554
+ help = "Show the tags that are present." ,
555
+ )
549
556
@add_options (* ROBOT_OPTIONS )
557
+ @click .option (
558
+ "--full-paths / --no-full-paths" ,
559
+ "full_paths" ,
560
+ default = False ,
561
+ show_default = True ,
562
+ help = "Show full paths instead of releative." ,
563
+ )
550
564
@pass_application
551
565
def all (
552
566
app : Application ,
567
+ full_paths : bool ,
568
+ show_tags : bool ,
553
569
by_longname : Tuple [str , ...],
554
570
exclude_by_longname : Tuple [str , ...],
555
571
robot_options_and_args : Tuple [str , ...],
@@ -578,25 +594,27 @@ def all(
578
594
def print (item : TestItem , indent : int = 0 ) -> Iterable [str ]:
579
595
type = click .style (
580
596
item .type .capitalize () if item .type == "suite" else tests_or_tasks .capitalize (),
581
- fg = "green " ,
597
+ fg = "blue " ,
582
598
)
583
599
584
600
if item .type == "test" :
585
- yield f" { type } : { item .longname } { os .linesep } "
601
+ yield " "
602
+ yield type
603
+ yield click .style (f": { item .longname } " , bold = True )
604
+ yield click .style (
605
+ f" ({ item .source if full_paths else item .rel_source } "
606
+ f":{ item .range .start .line + 1 if item .range is not None else 1 } ){ os .linesep } "
607
+ )
608
+ if show_tags and item .tags :
609
+ yield click .style (" Tags:" , bold = True , fg = "green" )
610
+ yield f" { ', ' . join (normalize (str (tag ), ignore = '_' ) for tag in sorted (item .tags ))} { os .linesep } "
586
611
else :
587
- yield f"{ type } : { item .longname } { os .linesep } "
588
-
612
+ yield type
613
+ yield f": { item .longname } "
614
+ yield click .style (f" ({ item .source if full_paths else item .rel_source } ){ os .linesep } " )
589
615
for child in item .children or []:
590
616
yield from print (child , indent + 2 )
591
617
592
- # type = click.style(
593
- # item.type.capitalize() if item.type == "suite" else tests_or_tasks.capitalize(), fg="green"
594
- # )
595
- # yield (f"{' ' * indent}{type}: {item.name}{os.linesep}")
596
- # if item.children:
597
- # for child in item.children:
598
- # yield from print(child, indent + 2)
599
-
600
618
if indent == 0 :
601
619
yield os .linesep
602
620
yield f"Summary:{ os .linesep } "
@@ -654,24 +672,27 @@ def tests(
654
672
```
655
673
"""
656
674
657
- _suite , collector , diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
675
+ suite , collector , diagnostics = handle_options (app , by_longname , exclude_by_longname , robot_options_and_args )
658
676
659
677
if collector .all .children :
660
678
if app .config .output_format is None or app .config .output_format == OutputFormat .TEXT :
661
679
680
+ tests_or_tasks = "Task" if suite .rpa else "Test"
681
+
662
682
def print (items : List [TestItem ]) -> Iterable [str ]:
663
683
for item in items :
664
- yield click .style (
665
- f"{ item .longname } " ,
666
- bold = True ,
667
- fg = "green" if show_tags else None ,
684
+ type = click .style (
685
+ item .type .capitalize () if item .type == "suite" else tests_or_tasks .capitalize (),
686
+ fg = "blue" ,
668
687
)
688
+ yield type
689
+ yield click .style (f": { item .longname } " , bold = True )
669
690
yield click .style (
670
691
f" ({ item .source if full_paths else item .rel_source } "
671
692
f":{ item .range .start .line + 1 if item .range is not None else 1 } ){ os .linesep } "
672
693
)
673
694
if show_tags and item .tags :
674
- yield click .style (" Tags:" , bold = True )
695
+ yield click .style (" Tags:" , bold = True , fg = "green" )
675
696
yield f" { ', ' . join (normalize (str (tag ), ignore = '_' ) for tag in sorted (item .tags ))} { os .linesep } "
676
697
677
698
if collector .tests :
@@ -687,9 +708,17 @@ def print(items: List[TestItem]) -> Iterable[str]:
687
708
epilog = 'Use "-- --help" to see `robot` help.' ,
688
709
)
689
710
@add_options (* ROBOT_OPTIONS )
711
+ @click .option (
712
+ "--full-paths / --no-full-paths" ,
713
+ "full_paths" ,
714
+ default = False ,
715
+ show_default = True ,
716
+ help = "Show full paths instead of releative." ,
717
+ )
690
718
@pass_application
691
719
def suites (
692
720
app : Application ,
721
+ full_paths : bool ,
693
722
by_longname : Tuple [str , ...],
694
723
exclude_by_longname : Tuple [str , ...],
695
724
robot_options_and_args : Tuple [str , ...],
@@ -716,7 +745,12 @@ def suites(
716
745
717
746
def print (items : List [TestItem ]) -> Iterable [str ]:
718
747
for item in items :
719
- yield f"{ item .longname } { os .linesep } "
748
+ # yield f"{item.longname}{os.linesep}"
749
+ yield click .style (
750
+ f"{ item .longname } " ,
751
+ bold = True ,
752
+ )
753
+ yield click .style (f" ({ item .source if full_paths else item .rel_source } ){ os .linesep } " )
720
754
721
755
if collector .suites :
722
756
app .echo_via_pager (print (collector .suites ))
0 commit comments