summaryrefslogtreecommitdiff
path: root/demoapp
diff options
context:
space:
mode:
authorDoug Hellmann <doug.hellmann@gmail.com>2012-04-22 15:03:15 -0700
committerDoug Hellmann <doug.hellmann@gmail.com>2012-04-22 15:03:15 -0700
commit35f42f9f8bf00a5bcdb2032d1e4535346c782289 (patch)
tree8bd46097e631585a48c2e9b808ddc9e26d9ec017 /demoapp
parent21b06cd2be7d42a04bad1db1428fb3269ad38fa1 (diff)
downloadcliff-35f42f9f8bf00a5bcdb2032d1e4535346c782289.tar.gz
tweak App api to make it easier to override and perform global actions before and after a command runs
Diffstat (limited to 'demoapp')
-rw-r--r--demoapp/cliffdemo/main.py10
-rw-r--r--demoapp/cliffdemo/simple.py3
2 files changed, 12 insertions, 1 deletions
diff --git a/demoapp/cliffdemo/main.py b/demoapp/cliffdemo/main.py
index 0a5b728..cebf552 100644
--- a/demoapp/cliffdemo/main.py
+++ b/demoapp/cliffdemo/main.py
@@ -1,3 +1,4 @@
+import logging
import sys
from cliff.app import App
@@ -5,6 +6,9 @@ from cliff.commandmanager import CommandManager
class DemoApp(App):
+
+ log = logging.getLogger(__name__)
+
def __init__(self):
super(DemoApp, self).__init__(
description='cliff demo app',
@@ -12,6 +16,12 @@ class DemoApp(App):
command_manager=CommandManager('cliff.demo'),
)
+ def prepare_to_run_command(self, cmd):
+ self.log.debug('prepare_to_run_command %s', cmd.__class__.__name__)
+
+ def clean_up(self, cmd, result):
+ self.log.debug('clean_up %s', cmd.__class__.__name__)
+
def main(argv=sys.argv[1:]):
myapp = DemoApp()
diff --git a/demoapp/cliffdemo/simple.py b/demoapp/cliffdemo/simple.py
index f4a16f8..2f273b9 100644
--- a/demoapp/cliffdemo/simple.py
+++ b/demoapp/cliffdemo/simple.py
@@ -9,5 +9,6 @@ class Simple(Command):
log = logging.getLogger(__name__)
def run(self, parsed_args):
+ self.log.info('sending greeting')
self.log.debug('debugging')
- self.log.info('hi!')
+ print('hi!')