nncli

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

commit b8a33108204de6f5fa5905d261dd36b9917b8469
parent 4d41e0cf5da752ba2dd784e47b996c959f0d30d3
Author: Alexey Shiklomanov <ashiklom@bu.edu>
Date:   Mon,  2 Oct 2017 17:47:43 -0400

Tag API: Add `tag rm`

Follows the same syntax as `tag add`.

Diffstat:
Msimplenote_cli/sncli.py | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/simplenote_cli/sncli.py b/simplenote_cli/sncli.py @@ -1235,6 +1235,24 @@ def cli_note_tags_add(self, key, new_tags): self.cli_note_tags_set(key, tags) + def cli_note_tags_rm(self, key, rm_tags): + + note = self.ndb.get_note(key) + if not note: + self.log('Error: Key does not exist') + return + + old_tags = self.cli_note_tags_get(key) + if old_tags: + old_tag_list = old_tags.split(',') + rm_tag_list = rm_tags.split(',') + tag_list = old_tag_list + for tag in rm_tag_list: + if tag in tag_list: + tag_list.remove(tag) + tags = ','.join(tag_list) + self.cli_note_tags_set(key, tags) + def SIGINT_handler(signum, frame): print('\nSignal caught, bye!') sys.exit(1) @@ -1272,6 +1290,7 @@ def usage(): tag get - retrieve the tags from a note (specified by <key>) tag set <tags> - set the tags for a note (specified by <key>) tag add <tags> - add tags to a note (specified by <key>) + tag rm <tags> - remove tags from a note (specified by <key>) ''') sys.exit(0) @@ -1421,6 +1440,12 @@ def sncli_start(sync=sync, verbose=verbose, config=config): sn = sncli_start() sn.cli_note_tags_add(key, new_tags) + elif args[1] == 'rm': + + rm_tags = args[2] + sn = sncli_start() + sn.cli_note_tags_rm(key, rm_tags) + else: usage()