nncli

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

commit db478ff1a02b1a705b6f43592a46e2cff222fb6a
parent 0d0908430f46cdc0b39c19db7a2074da936c9767
Author: Eric Davis <edavis@insanum.com>
Date:   Tue, 15 Jul 2014 18:17:18 -0700

new keybind command for restoring a previous version of a note

Diffstat:
Mconfig.py | 4+++-
Msncli.py | 16++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/config.py b/config.py @@ -39,7 +39,7 @@ def __init__(self): 'kb_edit_note' : 'e', 'kb_view_note' : 'enter', 'kb_view_note_ext' : 'meta enter', - 'kb_view_note_json' : 'R', + 'kb_view_note_json' : 'O', 'kb_pipe_note' : '|', 'kb_view_next_note' : 'J', 'kb_view_prev_note' : 'K', @@ -49,6 +49,7 @@ def __init__(self): 'kb_tabstop8' : '8', 'kb_prev_version' : '<', 'kb_next_version' : '>', + 'kb_restore_version' : 'R', 'kb_latest_version' : 'L', 'kb_select_version' : '#', 'kb_search_gstyle' : '/', @@ -161,6 +162,7 @@ def __init__(self): self.keybinds['tabstop8'] = [ cp.get(cfg_sec, 'kb_tabstop8'), [ 'notes' ], 'View with tabstop=8' ] self.keybinds['prev_version'] = [ cp.get(cfg_sec, 'kb_prev_version'), [ 'notes' ], 'View previous version' ] self.keybinds['next_version'] = [ cp.get(cfg_sec, 'kb_next_version'), [ 'notes' ], 'View next version' ] + self.keybinds['restore_version'] = [ cp.get(cfg_sec, 'kb_restore_version'), [ 'notes' ], 'Restore version of note' ] self.keybinds['latest_version'] = [ cp.get(cfg_sec, 'kb_latest_version'), [ 'notes' ], 'View latest version' ] self.keybinds['select_version'] = [ cp.get(cfg_sec, 'kb_select_version'), [ 'notes' ], 'Select version' ] self.keybinds['search_gstyle'] = [ cp.get(cfg_sec, 'kb_search_gstyle'), [ 'titles' ], 'Search using gstyle' ] diff --git a/sncli.py b/sncli.py @@ -427,6 +427,22 @@ def gui_frame_keypress(self, size, key): lb.update_note_view(version=version) + elif key == self.config.get_keybind('restore_version'): + if self.gui_body_get().__class__ != view_note.ViewNote: + return key + + if not self.view_note.old_note: + self.log(u'Already at latest version (key={0})'. + format(self.view_note.note['key'])) + return None + + self.log(u'Restoring version v{0} (key={1})'. + format(self.view_note.old_note['version'], + self.view_note.note['key'])) + self.ndb.set_note_content(self.view_note.note['key'], + self.view_note.old_note['content']) + lb.update_note_view() + elif key == self.config.get_keybind('latest_version'): if self.gui_body_get().__class__ != view_note.ViewNote: return key