Skip to content

Commit 5bf5493

Browse files
committed
feat(cli): add an astric (*) for options that can be used multiple times
1 parent 4ac5fd0 commit 5bf5493

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

.vscode/launch.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@
6666
// "E:\\source\\uvtestprj\\tests\\first.robotrepl"
6767
// "analyze",
6868
// "code",
69+
"--help"
6970
// "tests"
70-
"repl",
71+
//"repl",
7172
// "-v",
7273
// "asd:asd"
7374

packages/repl/src/robotcode/repl/cli/repl.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
Application,
1515
pass_application,
1616
)
17-
from robotcode.plugin.click_helper.aliases import AliasedCommand
1817
from robotcode.robot.utils import get_robot_version
1918
from robotcode.runner.cli.robot import RobotFrameworkEx, handle_robot_options
2019

@@ -115,8 +114,6 @@ def run_repl(
115114

116115

117116
@click.command(
118-
cls=AliasedCommand,
119-
aliases=["shell"],
120117
context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
121118
add_help_option=True,
122119
)

src/robotcode/cli/__init__.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
from .__version__ import __version__
2020
from .commands import config, profiles
2121

22+
old_make_metavar = click.Parameter.make_metavar
23+
24+
25+
def my_make_metavar(self: click.Parameter) -> str:
26+
metavar = old_make_metavar(self)
27+
28+
if isinstance(self, click.Option) and self.multiple:
29+
metavar += " *"
30+
31+
return metavar
32+
33+
34+
click.Parameter.make_metavar = my_make_metavar # type: ignore[method-assign]
35+
2236

2337
class RobotCodeFormatter(logging.Formatter):
2438
def __init__(self, *args: Any, **kwargs: Any) -> None:
@@ -38,8 +52,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
3852
multiple=True,
3953
show_envvar=True,
4054
help="""\
41-
Config file to use. Can be specified multiple times.
42-
If not specified, the default config file is used.
55+
Config file to use. If not specified, the default config file is used.
4356
""",
4457
)
4558
@click.option(
@@ -50,16 +63,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
5063
multiple=True,
5164
show_envvar=True,
5265
help="""\
53-
The Execution Profile to use. Can be specified multiple times.
54-
If not specified, the default profile is used.
66+
The Execution Profile to use. If not specified, the default profile is used.
5567
""",
5668
)
5769
@click.option(
5870
"-r",
5971
"--root",
6072
"root",
6173
type=click.Path(exists=True, path_type=Path, dir_okay=True, file_okay=False, resolve_path=True),
62-
multiple=False,
6374
show_envvar=True,
6475
help="Specifies the root path to be used for the project. It will be automatically detected if not provided.",
6576
)
@@ -157,8 +168,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
157168
type=click.Path(exists=False, resolve_path=False, path_type=str),
158169
multiple=True,
159170
hidden=show_hidden_arguments(),
160-
help="Default path to use if no path is given or defined in a profile. Can be specified multiple times. "
161-
"**This is an internal option for running in vscode",
171+
help="Default path to use if no path is given or defined in a profile. "
172+
"**This is an internal option for running in vscode**",
162173
)
163174
@click.option(
164175
"--launcher-script",

0 commit comments

Comments
 (0)