diff options
author | Richard Ipsum <richardipsum@fastmail.co.uk> | 2015-07-18 17:45:55 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-08-29 19:23:30 +0300 |
commit | 446e7ca2ed4ad7fe11519ad1744a2da7ca1bc4de (patch) | |
tree | 0cd9f2b4a33608c13748669e4d387bd9c84a784f /example2.py | |
parent | 23e24d7363d29c37acadbb51b3fa759a7885be18 (diff) | |
download | cliapp-446e7ca2ed4ad7fe11519ad1744a2da7ca1bc4de.tar.gz |
Add subcommand usage getter
Diffstat (limited to 'example2.py')
-rw-r--r-- | example2.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/example2.py b/example2.py index 972e880..fcee592 100644 --- a/example2.py +++ b/example2.py @@ -28,8 +28,8 @@ import cliapp class ExampleApp(cliapp.Application): cmd_synopsis = { - 'greet': '[USER]...', - 'insult': '[USER]...', + 'greet': 'USER...', + 'insult': 'USER...', } def cmd_greet(self, args): @@ -39,6 +39,9 @@ class ExampleApp(cliapp.Application): but terse form of greeting. ''' + if len(args) == 0: + raise cliapp.AppException(self.get_subcommand_usage('greet')) + for arg in args: self.output.write('greetings, %s\n' % arg) @@ -49,6 +52,9 @@ class ExampleApp(cliapp.Application): a prat, and needs to be told off. This is the command for that. ''' + if len(args) == 0: + raise cliapp.AppException(self.get_subcommand_usage('insult')) + for arg in args: self.output.write('you suck, %s\n' % arg) |