8
8
from robot .run import USAGE , RobotFramework
9
9
from robot .version import get_full_version
10
10
11
+ import robotcode .modifiers
11
12
from robotcode .plugin import Application , pass_application
12
13
from robotcode .plugin .click_helper .aliases import AliasedCommand
13
14
from robotcode .plugin .click_helper .types import add_options
@@ -25,13 +26,17 @@ def __init__(
25
26
paths : List [str ],
26
27
dry : bool ,
27
28
root_folder : Optional [Path ],
29
+ by_longname : Tuple [str , ...] = (),
30
+ exclude_by_longname : Tuple [str , ...] = (),
28
31
) -> None :
29
32
super ().__init__ ()
30
33
self .app = app
31
34
self .paths = paths
32
35
self .dry = dry
33
36
self .root_folder = root_folder
34
37
self ._orig_cwd = Path .cwd ()
38
+ self .by_longname = by_longname
39
+ self .exclude_by_longname = exclude_by_longname
35
40
36
41
def parse_arguments (self , cli_args : Any ) -> Any :
37
42
if self .root_folder is not None and Path .cwd () != self .root_folder :
@@ -61,6 +66,18 @@ def parse_arguments(self, cli_args: Any) -> Any:
61
66
f'{ line_end .join ((* (f"{ k } = { v !r} " for k , v in options .items ()), * arguments ))} '
62
67
)
63
68
69
+ modifiers = []
70
+ root_name = options .get ("name" , None )
71
+
72
+ if self .by_longname :
73
+ modifiers .append (robotcode .modifiers .ByLongName (* self .by_longname , root_name = root_name ))
74
+
75
+ if self .exclude_by_longname :
76
+ modifiers .append (robotcode .modifiers .ExcludedByLongName (* self .exclude_by_longname , root_name = root_name ))
77
+
78
+ if modifiers :
79
+ options ["prerunmodifier" ] = options .get ("prerunmodifier" , []) + modifiers
80
+
64
81
return options , arguments
65
82
66
83
@@ -90,10 +107,7 @@ def parse_arguments(self, cli_args: Any) -> Any:
90
107
91
108
92
109
def handle_robot_options (
93
- app : Application ,
94
- by_longname : Tuple [str , ...],
95
- exclude_by_longname : Tuple [str , ...],
96
- robot_options_and_args : Tuple [str , ...],
110
+ app : Application , robot_options_and_args : Tuple [str , ...]
97
111
) -> Tuple [Optional [Path ], RobotBaseProfile , List [str ]]:
98
112
robot_arguments : Optional [List [Union [str , Path ]]] = None
99
113
old_sys_path = sys .path .copy ()
@@ -118,20 +132,6 @@ def handle_robot_options(
118
132
119
133
cmd_options = profile .build_command_line ()
120
134
121
- if by_longname :
122
- sep = ";" if any (True for l in by_longname if ":" in l ) else ":"
123
- cmd_options += (
124
- "--prerunmodifier" ,
125
- f"robotcode.modifiers.ByLongName{ sep } { sep .join (by_longname )} " ,
126
- )
127
-
128
- if exclude_by_longname :
129
- sep = ";" if any (True for l in exclude_by_longname if ":" in l ) else ":"
130
- cmd_options += (
131
- "--prerunmodifier" ,
132
- f"robotcode.modifiers.ExcludedByLongName{ sep } { sep .join (exclude_by_longname )} " ,
133
- )
134
-
135
135
app .verbose (
136
136
lambda : "Executing robot with following options:\n "
137
137
+ " " .join (f'"{ o } "' for o in (cmd_options + list (robot_options_and_args )))
@@ -170,9 +170,7 @@ def robot(
170
170
```
171
171
"""
172
172
173
- root_folder , profile , cmd_options = handle_robot_options (
174
- app , by_longname , exclude_by_longname , robot_options_and_args
175
- )
173
+ root_folder , profile , cmd_options = handle_robot_options (app , robot_options_and_args )
176
174
177
175
app .exit (
178
176
cast (
@@ -186,6 +184,8 @@ def robot(
186
184
),
187
185
app .config .dry ,
188
186
root_folder ,
187
+ by_longname ,
188
+ exclude_by_longname ,
189
189
).execute_cli ((* cmd_options , * robot_options_and_args ), exit = False ),
190
190
)
191
191
)
0 commit comments