Ignoring convention that `--` separate non-flag arguments in bash (apart from last `--` for fire flags)
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 42/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 28.2k
- Forks
- 1.5k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de google/python-fire
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
google/python-fire#693 ·
-
Release 0.7.2? Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 38/100
google/python-fire#698 ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 58/100
google/python-fire#672 · 5 comentários ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
google/python-fire#665 · 2 comentários ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
google/python-fire#659 · 1 comentário ·
Todas as issues de google/python-fire
Issues semelhantes
-
agent-ready documentation needs-triage
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
-
documentation
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
-
instance instance add
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
searxng/searx-instances#939 · 1 comentário ·
-
area-deployment area-integrations triage:bot-seen
Dificuldade 2/5 Meio dia Facilidade para iniciantes 86/100