import fire
class Calculator(object):
"""A simple calculator."""
def double(self, number):
return 2 * number
if __name__ == '__main__':
fire.Fire(Calculator)
| Creating a CLI | Command | Notes |
|---|---|---|
| import | import fire |
- |
| Call | fire.Fire() |
Turns the current module into a Fire CLI. |
| Call | fire.Fire(component) |
Turns component into a Fire CLI. |
| Using a CLI | Command | Notes |
|---|---|---|
| Completion | command -- --completion |
Completion script |
| Trace | command -- --trace |
Trace the command. |
| Verbose | command -- --verbose |
- |
Note that flags are separated from the Fire command by an isolated -- arg.
See example .py files in the same dir as this notebook.