shell
pip install cliff
python
from cliff.app import App
from cliff.command import Command
python
class MyCLI(App):
def __init__(self):
super(MyCLI, self).__init__(
description='My Awesome CLI',
version='1.0',
command_manager=CommandManager('mycli.commands'),
)
def initialize_app(self, argv):
self.LOG.debug('Initializing MyCLI')
def prepare_to_run_command(self, cmd):
self.LOG.debug('Preparing to run command %s', cmd.__class__.__name__)
def clean_up(self, cmd, result, err):
self.LOG.debug('Cleaning up after command %s', cmd.__class__.__name__)
python
class HelloWorld(Command):
def take_action(self, parsed_args):
self.app.LOG.info('Hello, world!')
ini
[entry_points]
mycli.commands =
hello = mycli.commands:HelloWorld
shell
mycli hello