Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Ignoring convention that `--` separate non-flag arguments in bash (apart from last `--` for fire flags)

Aperta
#580 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

Start by reproducing the minimal test.py example and then inspect fire/core.py around line 376, where argument parsing is identified. Trace how multiple -- arguments are handled. Done means the earlier -- causes remaining arguments, including --flag 3, to be treated positionally while the final -- remains handled as shown in the expected output.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 - --help

Expected behavior:

python test.py -- other args 1 2 --flag 3 --
args=('args', 1, 2, "--flag", 3) flag=2

Would you be fine with updating the parsing rules in https://github.com/google/python-fire/blob/6cf45c663075c96b20dd0dfa733c2374545a4ad6/fire/core.py#L376 to consider all remaining args as positional arguments if it encounter a -- ? I could work on a PR if there is no major blocker.

Lingua principale
Python
Stelle
28.2k
Fork
1.5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di google/python-fire

Tutte le issue di google/python-fire

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.