Usage message is displayed when not desired.
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
Reproduziere das Verhalten mit dem bereitgestellten Beispiel fire_bug.py, einschließlich verketteter Befehle und --help. Beginne damit, die Pfade für die Befehlsausführung und die Hilfeanzeige von Python Fire nachzuverfolgen; abgeschlossen ist die Aufgabe, wenn gültige Befehle nicht mehr unaufgefordert Hilfe ausgeben, während Aufrufe ohne Befehl und mit --help nützliche Befehlsinformationen liefern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
When I build a class with methods that can be chained (they return self), I find that the "commands" help message is written out even when I provide commands with proper arguments and the commands are executed. Here is the code
from __future__ import annotations
from fire import Fire
class Foo:
def act(self, x: int) -> Foo:
"""
Act for some number of minutes.
Parameters
----------
x : int
The number of minutes to act.
"""
print("act", x, "minute(s)")
return self
def rest(self, x: int, y: str = "hours") -> Foo:
"""
Rest for a while.
Parameters
----------
x : int
The time to rest.
y : str
The units of x. The default is hours.
"""
print("rest", x, y)
return self
if __name__ == "__main__":
Fire(Foo)
If I run this as python fire_bug.py, I get the help output I expect, which is
NAME
fire_bug.py act 1
SYNOPSIS
fire_bug.py act 1 COMMAND
COMMANDS
COMMAND is one of the following:
act
Act for some number of minutes.
rest
Rest for a while.
If I run this as python fire_bug.py act 1, I unexpectedly get the help output
NAME
fire_bug.py act 1
SYNOPSIS
fire_bug.py act 1 COMMAND
COMMANDS
COMMAND is one of the following:
act
Act for some number of minutes.
rest
Rest for a while.
followed by the output I expect, which is
act 1 minute(s)
If run this as python fire_bug.py act 1 rest 9, I again unexpectedly get the help output
NAME
fire_bug.py act 1 rest 9
SYNOPSIS
fire_bug.py act 1 rest 9 - COMMAND
COMMANDS
COMMAND is one of the following:
act
Act for some number of minutes.
rest
Rest for a while.
followed by the output I expect, which is
act 1 minute(s)
rest 9 hours
If I add a __str__ method to the class that returns "\b", I don't get the unexpected messages, but I also don't get a help message if I run python fire_bug.py.
As a general observation, running python fire_bug.py --help does not produce useful output. The output is
NAME
fire_bug.py
SYNOPSIS
fire_bug.py -
The output I would expect would be the output I get when I run python fire_bug.py. I am aware that if I have an __init__ method with arguments that the information about those arguments will be displayed, but separating the two sets of information in this way is quite counterintuitive. Both sets of information should be provided when running with no command and when running with only a --help argument.
- Vorherrschende Sprache
- Python
- Sterne
- 28.2k
- Forks
- 1.5k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus google/python-fire
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
google/python-fire#693 ·
-
Release 0.7.2? Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 38/100
google/python-fire#698 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 58/100
google/python-fire#672 · 5 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
google/python-fire#665 · 2 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
google/python-fire#659 · 1 Kommentar ·
Alle Issues in google/python-fire
Ähnliche Issues
-
essnmx good first issue
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
-
[Feature] 奇物选择添加优先级 Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
syfoud/Simulated_Scepter#174 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Giskard-AI/giskard-oss#2840 · 1 Kommentar ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Offenarea: repo bug perceived difficulty: 2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
yeti-platform/yeti#1380 ·