diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-03-12 12:04:41 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-03-12 12:04:41 +0000 |
commit | 505061cce6ccd2ed1f668111b9b5b0471d162453 (patch) | |
tree | a3b049d39238821d633dbdd6761fed95b4728da4 /example.py | |
parent | 897c0d43ee56cd8327a21124a2169a37f3571b9f (diff) | |
download | cliapp-505061cce6ccd2ed1f668111b9b5b0471d162453.tar.gz |
Update example to use new settings API.
Diffstat (limited to 'example.py')
-rw-r--r-- | example.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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() |