-
I want to read the rest of the line into the last argument ignoring that it contains even existing options (as the script that I am going to run may contain the same options as the main script containing click. Using The best solution so far which unfortunately omits the launcher.py import pathlib
import click
@click.command(
context_settings=dict(
ignore_unknown_options=True,
)
)
@click.option(
"-d",
"--detach",
is_flag=True,
)
@click.argument("script_path", nargs=1, type=click.Path(exists=True, path_type=pathlib.Path))
@click.argument("script_args", nargs=-1, type=click.UNPROCESSED)
def run(detach: bool, script_path: pathlib.Path, script_args: tuple[str]) -> None:
print(f"Detach = {detach}")
print(f"Script args = {script_args}")
if __name__ == "__main__":
run() when I run the script
as you can see the '-d' flag is missing and yet '-d' flag was triggered which is undesired. I would expect ('-a', '-b', '-c', '-d', '-e') as a result. What is the proper way within the click to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Use
|
Beta Was this translation helpful? Give feedback.
Use
--
to separate options from tokens that must be treated as arguments.