python from cement import App, TestApp, init_defaults from cement.core.exc import CaughtSignal from cement.core import handler class MyApp(App): class Meta: label = 'myapp' config_defaults = init_defaults('myapp') config_handler = 'json' extensions = ['json'] handlers = [ 'myapp.commands.mycommand', ] class MyCommand(controller.CementBaseCommand): class Meta: label = 'mycommand' description = 'This is My Command' config_defaults = {'mycommand': {'option': 'value'}} @controller.expose(hide=True) def default(self): self.app.log.info('Inside MyCommand.default()') self.app.render({'key': 'value'}) def main(): with MyApp() as app: try: app.run() except CaughtSignal as e: print('Signal %s caught.' % e.signum) if __name__ == '__main__': main()


上一篇:
下一篇:
切换中文