-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Beyond the fact that fire uses the last -- to separate flag argument from command arguments, it seems that previous -- are not parsed correctly. At least according to the common convention that a double dash ( -- ) is used in most Bash built-in commands and many other commands to signify the end of command options, after which only positional ("non-option") arguments are accepted (source).
I would like to use this to pass some other commands to a fire command, without the flags targeted to the extra command being parsed by fire. Here is a minimal example test.py:
import fire
def foo(*args: str, flag: int = 2) -> None:
print(f"{args=} {flag=}")
fire.Fire(foo)Current behavior:
$ python test.py -- other args 1 2 --flag 3 --
args=('args', 1, 2) flag=3
ERROR: Could not consume arg: --
Usage: test.py -- other args 1 2 -
For detailed information on this command, run:
test.py -- other args 1 2 - --helpExpected behavior:
python test.py -- other args 1 2 --flag 3 --
args=('args', 1, 2, "--flag", 3) flag=2Would you be fine with updating the parsing rules in
Line 376 in 6cf45c6
| 2a. If the current component is a class, instantiate it using args from args. |
-- ? I could work on a PR if there is no major blocker.Metadata
Metadata
Assignees
Labels
No labels