|
| 1 | +## Python Fire Quick Reference |
| 2 | + |
1 | 3 | | Setup | Command | Notes
|
2 | 4 | | :------ | :------------------ | :---------
|
3 | 5 | | install | `pip install fire` |
|
|
8 | 10 | | Call | `fire.Fire()` | Turns the current module into a Fire CLI.
|
9 | 11 | | Call | `fire.Fire(component)` | Turns `component` into a Fire CLI.
|
10 | 12 |
|
11 |
| -| Using a CLI | Command | Notes |
12 |
| -| :------------- | :------------------------- | :--------- |
13 |
| -| [Help](using-cli.md#help-flag) | `command -- --help` | |
14 |
| -| [REPL](using-cli.md#interactive-flag) | `command -- --interactive` | Enters interactive mode. |
15 |
| -| [Separator](using-cli.md#separator-flag) | `command -- --separator=X` | This sets the separator to `X`. The default separator is `-`. |
16 |
| -| [Completion](using-cli.md#completion-flag) | `command -- --completion [shell]` | Generate a completion script for the CLI. |
17 |
| -| [Trace](using-cli.md#trace-flag) | `command -- --trace` | Gets a Fire trace for the command. |
18 |
| -| [Verbose](using-cli.md#verbose-flag) | `command -- --verbose` | |
| 13 | +| Using a CLI | Command | Notes | |
| 14 | +| :----------------------------------------- | :------------- | :------------- | |
| 15 | +| [Help](using-cli.md#help-flag) | `command | Show the help | |
| 16 | +: : --help` : screen. : |
| 17 | +| [REPL](using-cli.md#interactive-flag) | `command -- | Enters | |
| 18 | +: : --interactive` : interactive : |
| 19 | +: : : mode. : |
| 20 | +| [Separator](using-cli.md#separator-flag) | `command -- | This sets the | |
| 21 | +: : --separator=X` : separator to : |
| 22 | +: : : `X`. The : |
| 23 | +: : : default : |
| 24 | +: : : separator is : |
| 25 | +: : : `-`. : |
| 26 | +| [Completion](using-cli.md#completion-flag) | `command -- | Generate a | |
| 27 | +: : --completion : completion : |
| 28 | +: : [shell]` : script for the : |
| 29 | +: : : CLI. : |
| 30 | +| [Trace](using-cli.md#trace-flag) | `command -- | Gets a Fire | |
| 31 | +: : --trace` : trace for the : |
| 32 | +: : : command. : |
| 33 | +| [Verbose](using-cli.md#verbose-flag) | `command -- | | |
| 34 | +: : --verbose` : : |
| 35 | + |
| 36 | +_Note that flags are separated from the Fire command by an isolated `--` arg. |
| 37 | +Help is an exception; the isolated `--` is optional for getting help._ |
| 38 | + |
| 39 | +## Arguments for Calling fire.Fire() |
| 40 | + |
| 41 | +| Argument | Usage | Notes | |
| 42 | +| :-------- | :------------------------ | :----------------------------------- | |
| 43 | +| component | `fire.Fire(component)` | If omitted, defaults to a dict of | |
| 44 | +: : : all locals and globals. : |
| 45 | +| command | `fire.Fire(command='hello | Either a string or a list of | |
| 46 | +: : --name=5')` : arguments. If a string is provided, : |
| 47 | +: : : it is split to determine the : |
| 48 | +: : : arguments. If a list or tuple is : |
| 49 | +: : : provided, they are the arguments. If : |
| 50 | +: : : `command` is omitted, then : |
| 51 | +: : : `sys.argv[1\:]` (the arguments from : |
| 52 | +: : : the command line) are used by : |
| 53 | +: : : default. : |
| 54 | +| name | `fire.Fire(name='tool')` | The name of the CLI, ideally the | |
| 55 | +: : : name users will enter to run the : |
| 56 | +: : : CLI. This name will be used in the : |
| 57 | +: : : CLI's help screens. If the argument : |
| 58 | +: : : is omitted, it will be inferred : |
| 59 | +: : : automatically. : |
| 60 | + |
| 61 | +## Using a Fire CLI without modifying any code |
| 62 | + |
| 63 | +`python -m fire <module> <arguments>` |
19 | 64 |
|
20 |
| -_Note that flags are separated from the Fire command by an isolated `--` arg._ |
| 65 | +For example, `python -m fire calendar -h`. |
0 commit comments