summaryrefslogtreecommitdiff
path: root/example.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-03-12 12:04:41 +0000
committerLars Wirzenius <liw@liw.fi>2011-03-12 12:04:41 +0000
commit505061cce6ccd2ed1f668111b9b5b0471d162453 (patch)
treea3b049d39238821d633dbdd6761fed95b4728da4 /example.py
parent897c0d43ee56cd8327a21124a2169a37f3571b9f (diff)
downloadcliapp-505061cce6ccd2ed1f668111b9b5b0471d162453.tar.gz
Update example to use new settings API.
Diffstat (limited to 'example.py')
-rw-r--r--example.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/example.py b/example.py
index 0c60ae7..6182cc5 100644
--- a/example.py
+++ b/example.py
@@ -29,7 +29,8 @@ class ExampleApp(cliapp.Application):
'''A little fgrep-like tool.'''
def add_settings(self):
- self.add_string_list_setting(['pattern', 'e'], 'pattern to search for')
+ self.settings.add_string_list_setting(['pattern', 'e'],
+ 'pattern to search for')
# We override process_inputs to be able to do something after the last
# input line.
@@ -39,11 +40,13 @@ class ExampleApp(cliapp.Application):
self.output.write('There were %s matches.\n' % self.matches)
def process_input_line(self, name, line):
- for pattern in self['pattern']:
+ for pattern in self.settings['pattern']:
if pattern in line:
self.output.write('%s:%s: %s' % (name, self.lineno, line))
self.matches += 1
-ExampleApp(version='0.1.2').run()
+app = ExampleApp(version='0.1.2')
+app.settings.config_files = ['example.conf']
+app.run()