add bash completion

This commit is contained in:
Christophe Benz 2010-04-22 17:08:37 +02:00
commit a311ba455f
4 changed files with 69 additions and 7 deletions

View file

@ -59,6 +59,20 @@ class BaseApplication(object):
logging_options.add_option('-q', '--quiet', action='store_true', help='display only error messages')
logging_options.add_option('-v', '--verbose', action='store_true', help='display info messages')
self._parser.add_option_group(logging_options)
self._other_options = OptionGroup(self._parser, 'Other options')
self._other_options.add_option('--options', action='callback', callback=self.print_options,
help='print available options')
self._parser.add_option_group(self._other_options)
def print_options(self, option, opt, value, parser):
result = []
for o in self._parser._get_all_options():
if o._short_opts:
result.append(o._short_opts[0])
if o._long_opts:
result.append(o._long_opts[0])
print ' '.join(result)
sys.exit(0)
def create_weboob(self):
return Weboob(self.APPNAME)