Skip to main content

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


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)

Uploaded Source

Built Distribution

fire_cli_helper-0.2-py3-none-any.whl (8.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page