No project description provided
Project description
fire-commands
Easy to use helper library for creating google fire based CLIs
https://github.com/google/python-fire
See example application firehelper_example for usage.
CLI entry point
In the CLI entry point, import relevant CLI commands, and use start_fire_cli initialise the fire app.
import firehelper
from .commands import * #noqa
def main():
firehelper.start_fire_cli('firehelper_example')
if __name__ == '__main__':
main()
Commands
Import each command in the main app to ensure code to register the command is run.
To register commands:
print_commands = {
'print': lambda mytext: print(mytext)
}
firehelper.CommandRegistry.register(print_commands)
To register commands with subcommands:
maths_commands = {
'maths': {
'double': double,
'square': square
}
}
firehelper.CommandRegistry.register(maths_commands)
You can import all commands within a module as follows:
# commands.__init__.py
"""Ensure all commands to be registered are referenced here."""
__all__ = ['maths', 'print']
# __main__.py
from commands import * # noqa
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fire-cli-helper-0.2.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for fire_cli_helper-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d5daade4fb7933e07d18fc84191f925c0c817412bbc4bd3186135c9416c4445 |
|
MD5 | c0111786d2396853ea744df3175f1360 |
|
BLAKE2b-256 | 9640c73447c2d1a529812cbc167317980cb56fd912bc4c01ec1431b87654beb5 |