You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
$ 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 - --help
2a. If the current component is a class, instantiate it using args from args.
to consider all remaining args as positional arguments if it encounter a -- ? I could work on a PR if there is no major blocker.
The text was updated successfully, but these errors were encountered:
jbcdnr
changed the title
Ignoring convention that -- to separate non-flag arguments (more than -- one separating fire flags)
Ignoring convention that -- separate non-flag arguments (more than -- one separating fire flags)
Jan 22, 2025
jbcdnr
changed the title
Ignoring convention that -- separate non-flag arguments (more than -- one separating fire flags)
Ignoring convention that -- separate non-flag arguments in bash (apart from last -- for fire flags)
Jan 22, 2025
Could you have a look at this issue? I implemented the feature in this fork with some tests. Happy to open a PR and polish it if you agree that this is following expected behavior in bash (and argparse).
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
: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 - --help
Expected behavior:
Would you be fine with updating the parsing rules in
python-fire/fire/core.py
Line 376 in 6cf45c6
--
? I could work on a PR if there is no major blocker.The text was updated successfully, but these errors were encountered: