From 05e52debb27864695e59f66cd32fb60c3d40dc23 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 19 Jul 2013 11:43:52 +0100 Subject: Add subcommand help texts and arg synopsis --- clab | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/clab b/clab index 26ada94..d47700a 100755 --- a/clab +++ b/clab @@ -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') -- cgit v1.2.1