diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-07-19 11:43:52 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-07-19 11:43:52 +0100 |
commit | 05e52debb27864695e59f66cd32fb60c3d40dc23 (patch) | |
tree | 470d39af5a1884de5b2fa5b75a2582473cedd38d | |
parent | f7429bc8e038dd61a1efa699b3cda721f7eae3a8 (diff) | |
download | clab-05e52debb27864695e59f66cd32fb60c3d40dc23.tar.gz |
Add subcommand help texts and arg synopsis
-rwxr-xr-x | clab | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -87,6 +87,12 @@ class AddressBook(object): class CommandLineAddressBook(cliapp.Application): + cmd_synopsis = { + 'list': '', + 'find': '[PATTERN...]', + 'mutt-query': '[PATTERN...]', + } + def add_settings(self): self.settings.string_list( ['database', 'db', 'd'], @@ -101,16 +107,36 @@ class CommandLineAddressBook(cliapp.Application): return book def cmd_list(self, args): + '''List all entries in the database. + + This lists all the entries. See the find subcommand for + searching specific entries. + + ''' book = self.load_address_book() for entry in book.entries: self.output.write(entry.as_yaml() + '\n') def cmd_find(self, args): + '''List entries that match patterns. + + Each pattern is a fixed string (not a regular expression). + Matching is for any text in the entry. + + ''' + book = self.load_address_book() for entry in book.find(args): self.output.write(entry.as_yaml() + '\n') def cmd_mutt_query(self, args): + '''Find entries for use with mutt. + + This is like the find subcommand, but output is formatted + so it's suitable for the mutt query hook. + + ''' + if len(args) != 1: raise cliapp.AppException( 'mutt-query requires exactly one argument') |