diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-01-16 16:57:15 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-01-16 16:57:15 +0200 |
commit | 3c8b0338d786974ae9deaf93309b29b60ddde313 (patch) | |
tree | 8351622e0a0377e917e505964e33f29220513ed3 /example.py | |
parent | 4ac27e4a34ab223a258def4608a8de0c6ea36894 (diff) | |
download | cliapp-3c8b0338d786974ae9deaf93309b29b60ddde313.tar.gz |
Add use of add_options, process_input etc to example.py.
Diffstat (limited to 'example.py')
-rw-r--r-- | example.py | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -19,7 +19,18 @@ import cliapp class ExampleApp(cliapp.Application): - pass + '''A little fgrep-like tool.''' + + def add_options(self): + self.parser.add_option('--pattern', '-e', action='store', + help='the pattern to search for') + + def process_input(self, name): + f = open(name, 'r') + for line in f: + if self.options.pattern in line: + print line, + f.close() ExampleApp().run() |