bash
pip install cement
python
from cement import App, Controller, ex
class MyController(Controller):
class Meta:
label = 'mycontroller'
stacked_type = 'nested'
stacked_on = 'base'
@ex(help='This is a sample command')
def hello(self):
print('Hello, world!')
class MyApp(App):
class Meta:
label = 'myapp'
base_controller = 'base'
handlers = [MyController]
class base(Controller):
class Meta:
label = 'base'
usage = 'myapp'
description = 'My awesome command-line app'
@ex(help='Base command')
def base(self):
print('Base command')
if __name__ == '__main__':
with MyApp() as app:
app.run()
bash
python myapp.py hello
Hello, world!