nncli

NextCloud Notes Command Line Interface
git clone git://git.danielmoch.com/nncli.git
Log | Files | Refs | LICENSE

commit 45851f00325110dcbb6cf2ba59044b13140211f2
parent dc4f0e07853a5429ccbf500095f10310c3ca716c
Author: Eric Davis <edavis@insanum.com>
Date:   Sun, 13 Jul 2014 22:06:16 -0700

new command line argument to specifying search string is a regex

Diffstat:
Msncli.py | 26+++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/sncli.py b/sncli.py @@ -767,20 +767,24 @@ def gui(self, key): self.sncli_loop.run() - def cli_list_notes(self, search_string): + def cli_list_notes(self, regex, search_string): note_list, match_regex, all_notes_cnt = \ - self.ndb.filter_notes(search_string) + self.ndb.filter_notes( + search_string, + search_mode='regex' if regex else 'gstyle') for n in note_list: flags = utils.get_note_flags(n.note) print n.key + \ u' [' + flags + u'] ' + \ utils.get_note_title(n.note) - def cli_dump_notes(self, search_string): + def cli_dump_notes(self, regex, search_string): note_list, match_regex, all_notes_cnt = \ - self.ndb.filter_notes(search_string) + self.ndb.filter_notes( + search_string, + search_mode='regex' if regex else 'gstyle') for n in note_list: self.cli_note_dump(n.key) @@ -918,6 +922,7 @@ def usage(): -h, --help - usage help -v, --verbose - verbose output (cli mode) -n, --nosync - don't perform a server sync + -r, --regex - search string is a regular expression -k <key>, --key=<key> - note key -t <title>, --title=<title> - title of note for create (cli mode) @@ -936,15 +941,16 @@ def usage(): sys.exit(0) def main(argv): - sync = True verbose = False + sync = True + regex = False key = None title = None try: opts, args = getopt.getopt(argv, - 'hvnk:t:', - [ 'help', 'verbose' 'nosync', 'key=', 'title=' ]) + 'hvnrk:t:', + [ 'help', 'verbose' 'nosync', 'regex', 'key=', 'title=' ]) except: usage() @@ -955,6 +961,8 @@ def main(argv): verbose = True elif opt in [ '-n', '--nosync']: sync = False + elif opt in [ '-r', '--regex']: + regex = True elif opt in [ '-k', '--key']: key = arg elif opt in [ '-t', '--title']: @@ -978,7 +986,7 @@ def sncli_start(sync, verbose): elif args[0] == 'list': sn = sncli_start(sync, verbose) - sn.cli_list_notes(' '.join(args[1:])) + sn.cli_list_notes(regex, ' '.join(args[1:])) elif args[0] == 'dump': @@ -986,7 +994,7 @@ def sncli_start(sync, verbose): if key: sn.cli_note_dump(key) else: - sn.cli_dump_notes(' '.join(args[1:])) + sn.cli_dump_notes(regex, ' '.join(args[1:])) elif args[0] == 'create':