diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-05-26 16:13:53 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-05-26 16:13:53 +0100 |
commit | a2ca05b5281abe60c99cf623743b1b1b74b279ac (patch) | |
tree | 29c3d5b1f46e10508a2c90a300f6d637a4a387ae /example2.py | |
parent | c5453a55f85d5aad9ac5d4abd10084aca0533e87 (diff) | |
download | cliapp-a2ca05b5281abe60c99cf623743b1b1b74b279ac.tar.gz |
Add example using subcommands.
Diffstat (limited to 'example2.py')
-rw-r--r-- | example2.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/example2.py b/example2.py new file mode 100644 index 0000000..1a8911b --- /dev/null +++ b/example2.py @@ -0,0 +1,42 @@ +# Copyright 2011 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +'''Example for cliapp framework. + +Greet or insult people. + +''' + + +import cliapp +import logging + + +class ExampleApp(cliapp.Application): + + def cmd_greet(self, args): + for arg in args: + self.output.write('greetings, %s\n' % arg) + + def cmd_insult(self, args): + for arg in args: + self.output.write('you suck, %s\n' % arg) + + +app = ExampleApp(version='0.1.2') +app.settings.config_files = ['example.conf'] +app.run() + |