fireaid 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fireaid-0.1.0/LICENSE +21 -0
- fireaid-0.1.0/MANIFEST.in +3 -0
- fireaid-0.1.0/Makefile +19 -0
- fireaid-0.1.0/PKG-INFO +164 -0
- fireaid-0.1.0/README.md +148 -0
- fireaid-0.1.0/examples/pantry.py +93 -0
- fireaid-0.1.0/examples/tour.sh +63 -0
- fireaid-0.1.0/pyproject.toml +38 -0
- fireaid-0.1.0/setup.cfg +4 -0
- fireaid-0.1.0/src/fireaid/__init__.py +400 -0
- fireaid-0.1.0/src/fireaid/__main__.py +28 -0
- fireaid-0.1.0/src/fireaid.egg-info/PKG-INFO +164 -0
- fireaid-0.1.0/src/fireaid.egg-info/SOURCES.txt +21 -0
- fireaid-0.1.0/src/fireaid.egg-info/dependency_links.txt +1 -0
- fireaid-0.1.0/src/fireaid.egg-info/requires.txt +4 -0
- fireaid-0.1.0/src/fireaid.egg-info/top_level.txt +1 -0
- fireaid-0.1.0/tests/cli.py +90 -0
- fireaid-0.1.0/tests/conftest.py +71 -0
- fireaid-0.1.0/tests/test_examples.py +34 -0
- fireaid-0.1.0/tests/test_help.py +191 -0
- fireaid-0.1.0/tests/test_module.py +204 -0
- fireaid-0.1.0/tests/test_terminal.py +83 -0
- fireaid-0.1.0/tests/test_transparency.py +79 -0
fireaid-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Christiane Ruetten
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
fireaid-0.1.0/Makefile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
PYTHON ?= python3
|
|
2
|
+
VENV := .venv
|
|
3
|
+
|
|
4
|
+
.PHONY: test clean
|
|
5
|
+
|
|
6
|
+
# Tests run against the latest stable Fire, whatever was installed before.
|
|
7
|
+
test: $(VENV)
|
|
8
|
+
$(VENV)/bin/pip install --quiet --upgrade fire
|
|
9
|
+
$(VENV)/bin/pytest
|
|
10
|
+
|
|
11
|
+
$(VENV): pyproject.toml
|
|
12
|
+
$(PYTHON) -m venv $(VENV)
|
|
13
|
+
$(VENV)/bin/pip install --quiet --upgrade pip
|
|
14
|
+
$(VENV)/bin/pip install --quiet --editable ".[test]"
|
|
15
|
+
touch $(VENV)
|
|
16
|
+
|
|
17
|
+
clean:
|
|
18
|
+
rm -rf $(VENV) .pytest_cache build dist src/fireaid.egg-info
|
|
19
|
+
find . -name __pycache__ -not -path "./.git/*" -prune -exec rm -rf {} +
|
fireaid-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fireaid
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Familiar help for command-line tools made with Python Fire
|
|
5
|
+
Author-email: Christiane Ruetten <cr@23bit.net>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/cr/fireaid
|
|
8
|
+
Project-URL: Repository, https://github.com/cr/fireaid
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: fire>=0.2.0
|
|
13
|
+
Provides-Extra: test
|
|
14
|
+
Requires-Dist: pytest; extra == "test"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# fireaid
|
|
18
|
+
|
|
19
|
+
*A little help for Python Fire.*
|
|
20
|
+
|
|
21
|
+
[Python Fire](https://github.com/google/python-fire) turns any Python
|
|
22
|
+
function, class or module into a command-line tool with a single line
|
|
23
|
+
of code. `fireaid` is a thin wrapper around it that adds the help
|
|
24
|
+
conventions people know from tools like `git`: a `help` command,
|
|
25
|
+
`--help` printed plainly to the terminal, and a short usage message
|
|
26
|
+
when a command is incomplete. Everything else is Fire, unchanged.
|
|
27
|
+
|
|
28
|
+
All you need is:
|
|
29
|
+
|
|
30
|
+
pip install git+https://github.com/cr/fireaid
|
|
31
|
+
|
|
32
|
+
import fireaid as fire
|
|
33
|
+
|
|
34
|
+
fire.Fire(MyTool)
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
Directly from the repository:
|
|
39
|
+
|
|
40
|
+
pip install git+https://github.com/cr/fireaid
|
|
41
|
+
|
|
42
|
+
As a dependency in another project's `pyproject.toml`:
|
|
43
|
+
|
|
44
|
+
dependencies = ["fireaid @ git+https://github.com/cr/fireaid"]
|
|
45
|
+
|
|
46
|
+
From the project directory:
|
|
47
|
+
|
|
48
|
+
pip install .
|
|
49
|
+
|
|
50
|
+
For development:
|
|
51
|
+
|
|
52
|
+
pip install -e .
|
|
53
|
+
|
|
54
|
+
fireaid requires Fire 0.2.0 or later, the first version to accept
|
|
55
|
+
`--help` without a separator. On Python 3.13 and later, Fire itself
|
|
56
|
+
requires version 0.7.0.
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
Change:
|
|
61
|
+
|
|
62
|
+
import fire
|
|
63
|
+
|
|
64
|
+
to:
|
|
65
|
+
|
|
66
|
+
import fireaid as fire
|
|
67
|
+
|
|
68
|
+
Existing code such as:
|
|
69
|
+
|
|
70
|
+
fire.Fire(MyCLI)
|
|
71
|
+
|
|
72
|
+
continues to work, as do `import fireaid.core` and `python -m fireaid`.
|
|
73
|
+
|
|
74
|
+
## Help
|
|
75
|
+
|
|
76
|
+
Python Fire accepts:
|
|
77
|
+
|
|
78
|
+
tool foo -- --help
|
|
79
|
+
tool foo --help
|
|
80
|
+
tool foo -h
|
|
81
|
+
|
|
82
|
+
fireaid additionally supports Git-style help:
|
|
83
|
+
|
|
84
|
+
tool help
|
|
85
|
+
tool help foo
|
|
86
|
+
tool help foo bar
|
|
87
|
+
|
|
88
|
+
`help` is a command like any other: Fire lists it with the program's
|
|
89
|
+
commands in the usage text and in the help, and `tool help help` shows
|
|
90
|
+
help for it.
|
|
91
|
+
To that end, fireaid adds the command to the program for as long as
|
|
92
|
+
Fire runs: to its class, or to a copy if the program is a dict.
|
|
93
|
+
|
|
94
|
+
With `--help` and `-h`, fireaid also
|
|
95
|
+
|
|
96
|
+
- prints the help text to stdout, so that `tool --help | less` works,
|
|
97
|
+
- prints it as it is, where Fire starts a pager on a terminal,
|
|
98
|
+
- omits Fire's `INFO: Showing help with the command ...` banner,
|
|
99
|
+
- shows help for functions taking `**kwargs`, where Fire passes
|
|
100
|
+
`help=True` to the function.
|
|
101
|
+
|
|
102
|
+
Native Fire syntax continues to work unchanged, printing to stderr,
|
|
103
|
+
or to a pager on a terminal.
|
|
104
|
+
|
|
105
|
+
## Usage text
|
|
106
|
+
|
|
107
|
+
A command line that names a group rather than a command, such as
|
|
108
|
+
plain `tool`, is a success to Fire, which shows the full help for the
|
|
109
|
+
group, in a pager. To fireaid it is an incomplete command, as it is to
|
|
110
|
+
Git: it prints Fire's short usage text to stdout, and exits with 2,
|
|
111
|
+
Fire's exit code for errors:
|
|
112
|
+
|
|
113
|
+
Usage: tool <group|command>
|
|
114
|
+
available groups: shelf
|
|
115
|
+
available commands: add | help | list | remove | search
|
|
116
|
+
|
|
117
|
+
For detailed information on this command, run:
|
|
118
|
+
tool --help
|
|
119
|
+
|
|
120
|
+
A function that returns an object is a complete command. There, Fire
|
|
121
|
+
shows the help for the object, which fireaid only keeps from the pager.
|
|
122
|
+
|
|
123
|
+
`examples/pantry.py` is a small program to try all of this on, and
|
|
124
|
+
`examples/tour.sh` runs through it.
|
|
125
|
+
|
|
126
|
+
## Limits
|
|
127
|
+
|
|
128
|
+
fireaid does not take anything away from the wrapped program:
|
|
129
|
+
|
|
130
|
+
- `help` is only help as the first word, and not if the program has
|
|
131
|
+
a `help` command of its own, or is a single function.
|
|
132
|
+
- `--help` and `-h` are only help as the last word. `--help` is left
|
|
133
|
+
to a command with a `help` parameter, `-h` to a command with a
|
|
134
|
+
parameter starting with `h`, for which it is Fire's shortcut.
|
|
135
|
+
- A command that fireaid cannot find without running the program, such
|
|
136
|
+
as a member created in `__init__`, may have such a parameter. There,
|
|
137
|
+
`-h` is left to Fire, which shows help with its banner on stderr.
|
|
138
|
+
|
|
139
|
+
Help for a command that does not exist is an error, as it is in
|
|
140
|
+
Fire's native syntax.
|
|
141
|
+
|
|
142
|
+
As with Fire, help is shown for what the command line evaluates to.
|
|
143
|
+
`tool foo x --help` calls `foo` and shows help for its result. Ask
|
|
144
|
+
for `tool foo --help` to get help for `foo`.
|
|
145
|
+
|
|
146
|
+
## Tests
|
|
147
|
+
|
|
148
|
+
make test
|
|
149
|
+
|
|
150
|
+
creates a virtual environment in `.venv`, upgrades it to the latest
|
|
151
|
+
stable Fire, and runs the test suite. The tests hold fireaid to what
|
|
152
|
+
this README says, mostly by comparing it to Fire on the same command
|
|
153
|
+
lines. `make test PYTHON=python3.14` selects the Python for a new
|
|
154
|
+
environment, `make clean` removes it.
|
|
155
|
+
|
|
156
|
+
## Releasing
|
|
157
|
+
|
|
158
|
+
Set the new `version` in `pyproject.toml`, commit, then tag and push:
|
|
159
|
+
|
|
160
|
+
git tag v0.1.0 && git push origin main v0.1.0
|
|
161
|
+
|
|
162
|
+
The tag starts `.github/workflows/publish.yml`, which runs the tests,
|
|
163
|
+
checks that the tag is the package version, builds, and publishes to
|
|
164
|
+
PyPI as a trusted publisher. PyPI never takes the same version twice.
|
fireaid-0.1.0/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# fireaid
|
|
2
|
+
|
|
3
|
+
*A little help for Python Fire.*
|
|
4
|
+
|
|
5
|
+
[Python Fire](https://github.com/google/python-fire) turns any Python
|
|
6
|
+
function, class or module into a command-line tool with a single line
|
|
7
|
+
of code. `fireaid` is a thin wrapper around it that adds the help
|
|
8
|
+
conventions people know from tools like `git`: a `help` command,
|
|
9
|
+
`--help` printed plainly to the terminal, and a short usage message
|
|
10
|
+
when a command is incomplete. Everything else is Fire, unchanged.
|
|
11
|
+
|
|
12
|
+
All you need is:
|
|
13
|
+
|
|
14
|
+
pip install git+https://github.com/cr/fireaid
|
|
15
|
+
|
|
16
|
+
import fireaid as fire
|
|
17
|
+
|
|
18
|
+
fire.Fire(MyTool)
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Directly from the repository:
|
|
23
|
+
|
|
24
|
+
pip install git+https://github.com/cr/fireaid
|
|
25
|
+
|
|
26
|
+
As a dependency in another project's `pyproject.toml`:
|
|
27
|
+
|
|
28
|
+
dependencies = ["fireaid @ git+https://github.com/cr/fireaid"]
|
|
29
|
+
|
|
30
|
+
From the project directory:
|
|
31
|
+
|
|
32
|
+
pip install .
|
|
33
|
+
|
|
34
|
+
For development:
|
|
35
|
+
|
|
36
|
+
pip install -e .
|
|
37
|
+
|
|
38
|
+
fireaid requires Fire 0.2.0 or later, the first version to accept
|
|
39
|
+
`--help` without a separator. On Python 3.13 and later, Fire itself
|
|
40
|
+
requires version 0.7.0.
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
Change:
|
|
45
|
+
|
|
46
|
+
import fire
|
|
47
|
+
|
|
48
|
+
to:
|
|
49
|
+
|
|
50
|
+
import fireaid as fire
|
|
51
|
+
|
|
52
|
+
Existing code such as:
|
|
53
|
+
|
|
54
|
+
fire.Fire(MyCLI)
|
|
55
|
+
|
|
56
|
+
continues to work, as do `import fireaid.core` and `python -m fireaid`.
|
|
57
|
+
|
|
58
|
+
## Help
|
|
59
|
+
|
|
60
|
+
Python Fire accepts:
|
|
61
|
+
|
|
62
|
+
tool foo -- --help
|
|
63
|
+
tool foo --help
|
|
64
|
+
tool foo -h
|
|
65
|
+
|
|
66
|
+
fireaid additionally supports Git-style help:
|
|
67
|
+
|
|
68
|
+
tool help
|
|
69
|
+
tool help foo
|
|
70
|
+
tool help foo bar
|
|
71
|
+
|
|
72
|
+
`help` is a command like any other: Fire lists it with the program's
|
|
73
|
+
commands in the usage text and in the help, and `tool help help` shows
|
|
74
|
+
help for it.
|
|
75
|
+
To that end, fireaid adds the command to the program for as long as
|
|
76
|
+
Fire runs: to its class, or to a copy if the program is a dict.
|
|
77
|
+
|
|
78
|
+
With `--help` and `-h`, fireaid also
|
|
79
|
+
|
|
80
|
+
- prints the help text to stdout, so that `tool --help | less` works,
|
|
81
|
+
- prints it as it is, where Fire starts a pager on a terminal,
|
|
82
|
+
- omits Fire's `INFO: Showing help with the command ...` banner,
|
|
83
|
+
- shows help for functions taking `**kwargs`, where Fire passes
|
|
84
|
+
`help=True` to the function.
|
|
85
|
+
|
|
86
|
+
Native Fire syntax continues to work unchanged, printing to stderr,
|
|
87
|
+
or to a pager on a terminal.
|
|
88
|
+
|
|
89
|
+
## Usage text
|
|
90
|
+
|
|
91
|
+
A command line that names a group rather than a command, such as
|
|
92
|
+
plain `tool`, is a success to Fire, which shows the full help for the
|
|
93
|
+
group, in a pager. To fireaid it is an incomplete command, as it is to
|
|
94
|
+
Git: it prints Fire's short usage text to stdout, and exits with 2,
|
|
95
|
+
Fire's exit code for errors:
|
|
96
|
+
|
|
97
|
+
Usage: tool <group|command>
|
|
98
|
+
available groups: shelf
|
|
99
|
+
available commands: add | help | list | remove | search
|
|
100
|
+
|
|
101
|
+
For detailed information on this command, run:
|
|
102
|
+
tool --help
|
|
103
|
+
|
|
104
|
+
A function that returns an object is a complete command. There, Fire
|
|
105
|
+
shows the help for the object, which fireaid only keeps from the pager.
|
|
106
|
+
|
|
107
|
+
`examples/pantry.py` is a small program to try all of this on, and
|
|
108
|
+
`examples/tour.sh` runs through it.
|
|
109
|
+
|
|
110
|
+
## Limits
|
|
111
|
+
|
|
112
|
+
fireaid does not take anything away from the wrapped program:
|
|
113
|
+
|
|
114
|
+
- `help` is only help as the first word, and not if the program has
|
|
115
|
+
a `help` command of its own, or is a single function.
|
|
116
|
+
- `--help` and `-h` are only help as the last word. `--help` is left
|
|
117
|
+
to a command with a `help` parameter, `-h` to a command with a
|
|
118
|
+
parameter starting with `h`, for which it is Fire's shortcut.
|
|
119
|
+
- A command that fireaid cannot find without running the program, such
|
|
120
|
+
as a member created in `__init__`, may have such a parameter. There,
|
|
121
|
+
`-h` is left to Fire, which shows help with its banner on stderr.
|
|
122
|
+
|
|
123
|
+
Help for a command that does not exist is an error, as it is in
|
|
124
|
+
Fire's native syntax.
|
|
125
|
+
|
|
126
|
+
As with Fire, help is shown for what the command line evaluates to.
|
|
127
|
+
`tool foo x --help` calls `foo` and shows help for its result. Ask
|
|
128
|
+
for `tool foo --help` to get help for `foo`.
|
|
129
|
+
|
|
130
|
+
## Tests
|
|
131
|
+
|
|
132
|
+
make test
|
|
133
|
+
|
|
134
|
+
creates a virtual environment in `.venv`, upgrades it to the latest
|
|
135
|
+
stable Fire, and runs the test suite. The tests hold fireaid to what
|
|
136
|
+
this README says, mostly by comparing it to Fire on the same command
|
|
137
|
+
lines. `make test PYTHON=python3.14` selects the Python for a new
|
|
138
|
+
environment, `make clean` removes it.
|
|
139
|
+
|
|
140
|
+
## Releasing
|
|
141
|
+
|
|
142
|
+
Set the new `version` in `pyproject.toml`, commit, then tag and push:
|
|
143
|
+
|
|
144
|
+
git tag v0.1.0 && git push origin main v0.1.0
|
|
145
|
+
|
|
146
|
+
The tag starts `.github/workflows/publish.yml`, which runs the tests,
|
|
147
|
+
checks that the tag is the package version, builds, and publishes to
|
|
148
|
+
PyPI as a trusted publisher. PyPI never takes the same version twice.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
A pantry manager, to show off fireaid's help.
|
|
4
|
+
|
|
5
|
+
Run examples/tour.sh to see all of the below, or try:
|
|
6
|
+
|
|
7
|
+
pantry.py --help
|
|
8
|
+
pantry.py help
|
|
9
|
+
pantry.py help add
|
|
10
|
+
pantry.py add --help
|
|
11
|
+
pantry.py shelf -h
|
|
12
|
+
pantry.py help shelf label
|
|
13
|
+
pantry.py list --help
|
|
14
|
+
pantry.py search --help
|
|
15
|
+
pantry.py search milk -h
|
|
16
|
+
pantry.py add -- --help
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import fireaid as fire
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Shelf:
|
|
23
|
+
"""A shelf of the pantry."""
|
|
24
|
+
|
|
25
|
+
def label(self, text):
|
|
26
|
+
"""Label the shelf.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
text: The text to write on the label.
|
|
30
|
+
"""
|
|
31
|
+
return f"Shelf labelled {text!r}."
|
|
32
|
+
|
|
33
|
+
def clear(self):
|
|
34
|
+
"""Take everything off the shelf."""
|
|
35
|
+
return "Shelf cleared."
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Pantry:
|
|
39
|
+
"""Keep track of what is in the pantry.
|
|
40
|
+
|
|
41
|
+
Ask for help with --help, -h or help, at any level:
|
|
42
|
+
|
|
43
|
+
pantry.py help
|
|
44
|
+
pantry.py add --help
|
|
45
|
+
pantry.py help shelf label
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def __init__(self):
|
|
49
|
+
self.shelf = Shelf()
|
|
50
|
+
|
|
51
|
+
def add(self, item, quantity=1, expires=None):
|
|
52
|
+
"""Put an item into the pantry.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
item: What to put in.
|
|
56
|
+
quantity: How many of it.
|
|
57
|
+
expires: A date, or nothing for things that keep.
|
|
58
|
+
"""
|
|
59
|
+
when = f", best before {expires}" if expires else ""
|
|
60
|
+
return f"Added {quantity} x {item}{when}."
|
|
61
|
+
|
|
62
|
+
def remove(self, item, quantity=1):
|
|
63
|
+
"""Take an item out of the pantry."""
|
|
64
|
+
return f"Removed {quantity} x {item}."
|
|
65
|
+
|
|
66
|
+
def list(self, **filters):
|
|
67
|
+
"""List the pantry, optionally filtered.
|
|
68
|
+
|
|
69
|
+
Filters are free-form, such as --shelf=top or --expired=true.
|
|
70
|
+
Fire would take --help for a filter here; fireaid shows help.
|
|
71
|
+
"""
|
|
72
|
+
if filters:
|
|
73
|
+
return f"Listing items where {filters}."
|
|
74
|
+
return "Listing all items."
|
|
75
|
+
|
|
76
|
+
def search(self, pattern, hidden=False):
|
|
77
|
+
"""Search the pantry.
|
|
78
|
+
|
|
79
|
+
-h is Fire's shortcut for --hidden, so 'search milk -h' searches
|
|
80
|
+
hidden items, while 'search --help' shows this help.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
pattern: A substring of the item name.
|
|
84
|
+
hidden: Also search items hidden at the back.
|
|
85
|
+
"""
|
|
86
|
+
where = "everywhere" if hidden else "in plain sight"
|
|
87
|
+
return f"Searching for {pattern!r} {where}."
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if __name__ == "__main__":
|
|
91
|
+
# An instance rather than the class: Fire then lists the commands in
|
|
92
|
+
# the top-level help, and fireaid sees members created in __init__.
|
|
93
|
+
fire.Fire(Pantry())
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# A tour of fireaid's help syntax, run on examples/pantry.py.
|
|
3
|
+
#
|
|
4
|
+
# Every command is printed before it runs. The pager is switched off so
|
|
5
|
+
# that the output is plain text.
|
|
6
|
+
|
|
7
|
+
cd "$(dirname "$0")" || exit 1
|
|
8
|
+
export PAGER=cat
|
|
9
|
+
|
|
10
|
+
demo() {
|
|
11
|
+
printf '\n$ pantry.py %s\n' "$*"
|
|
12
|
+
python3 pantry.py "$@"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
echo '### An incomplete command gets the usage, and exit code 2'
|
|
16
|
+
demo
|
|
17
|
+
echo "(exit code $?)"
|
|
18
|
+
demo shelf
|
|
19
|
+
|
|
20
|
+
echo
|
|
21
|
+
echo '### Help at the top level, three ways'
|
|
22
|
+
demo --help
|
|
23
|
+
demo -h
|
|
24
|
+
demo help
|
|
25
|
+
|
|
26
|
+
echo
|
|
27
|
+
echo '### Help for a command, and Git-style help'
|
|
28
|
+
demo add --help
|
|
29
|
+
demo help add
|
|
30
|
+
|
|
31
|
+
echo
|
|
32
|
+
echo '### help is a command like any other, with help of its own'
|
|
33
|
+
demo help help
|
|
34
|
+
|
|
35
|
+
echo
|
|
36
|
+
echo '### Help for a group and a command within it'
|
|
37
|
+
demo shelf -h
|
|
38
|
+
demo help shelf label
|
|
39
|
+
|
|
40
|
+
echo
|
|
41
|
+
echo '### Fire itself would pass --help to a **kwargs function as a filter'
|
|
42
|
+
demo list --help
|
|
43
|
+
|
|
44
|
+
echo
|
|
45
|
+
echo '### -h stays the shortcut for a parameter starting with h'
|
|
46
|
+
demo search --help
|
|
47
|
+
demo search milk -h
|
|
48
|
+
|
|
49
|
+
echo
|
|
50
|
+
echo "### Fire's native syntax is untouched, and prints to stderr"
|
|
51
|
+
printf '\n$ pantry.py add -- --help 2>/dev/null | head -3\n'
|
|
52
|
+
python3 pantry.py add -- --help 2>/dev/null | head -3
|
|
53
|
+
echo '(nothing, it all went to stderr)'
|
|
54
|
+
|
|
55
|
+
echo
|
|
56
|
+
echo '### fireaid prints help to stdout, so it can be piped'
|
|
57
|
+
printf '\n$ pantry.py add --help 2>/dev/null | head -3\n'
|
|
58
|
+
python3 pantry.py add --help 2>/dev/null | head -3
|
|
59
|
+
|
|
60
|
+
echo
|
|
61
|
+
echo '### Help after arguments is help for the result, as in Fire'
|
|
62
|
+
printf '\n$ pantry.py add milk 2 --help | head -8\n'
|
|
63
|
+
python3 pantry.py add milk 2 --help | head -8
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fireaid"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Familiar help for command-line tools made with Python Fire"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Christiane Ruetten", email = "cr@23bit.net"}
|
|
15
|
+
]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"fire>=0.2.0"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
test = [
|
|
22
|
+
"pytest"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/cr/fireaid"
|
|
27
|
+
Repository = "https://github.com/cr/fireaid"
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["src"]
|
|
31
|
+
|
|
32
|
+
[tool.pytest.ini_options]
|
|
33
|
+
testpaths = ["tests"]
|
|
34
|
+
# Fire 0.7.1 calls a function deprecated in Python 3.14 and removed in 3.16.
|
|
35
|
+
# Remove this filter once Fire has replaced it.
|
|
36
|
+
filterwarnings = [
|
|
37
|
+
"ignore:'asyncio.iscoroutinefunction' is deprecated:DeprecationWarning:fire",
|
|
38
|
+
]
|
fireaid-0.1.0/setup.cfg
ADDED