def parser(options): # Find the nearest repo repo = Repo.findrepo(options.repo) # Adjust path path = repo.relpath(options.path) # Ensure the note exists before attempting to work on it if path not in repo.notes: raise HuskError("{} note does not exist".format(path)) editor = repo.config.get("general", "editor", os.environ.get("EDITOR")) if not editor: raise HuskError( 'Cannot open notes. The "general.editor" ' "setting nor the $EDITOR environment variable are defined." ) args = shlex.split(editor) + repo.notes[path].files retcode = subprocess.call(args) if retcode != 0: raise HuskError( "Editor had a non-successful exit. Nothing has been " "committed. To manually commit, use `husk commit`." )
def parser(options): # Find the nearest repo repo = Repo.findrepo(options.repo) src = repo.relpath(options.src) dest = repo.relpath(options.dest) repo.notes.move(src, dest)
def parser(options): # Find the nearest repo repo = Repo.findrepo(options.repo) for path in options.path: # Ensure the path is defined relative to the repo repo.notes.add(repo.relpath(path), defer=True) repo.notes.todisk()
def parser(options): # Find the nearest repo repo = Repo.findrepo(options.repo) if 'notes' in options.stats: print('{} notes'.format(len(repo.notes))) print('-' * 5) for note in repo.notes: print(repo.relpath(note.path))
def parser(options): # Find the nearest repo repo = Repo.findrepo(options.repo) # Adjust path path = repo.relpath(options.path) # Ensure the note exists before attempting to work on it if path not in repo.notes: raise HuskError('{} note does not exist'.format(path)) editor = repo.config.get('general', 'editor', os.environ.get('EDITOR')) if not editor: raise HuskError('Cannot open notes. The "general.editor" ' \ 'setting nor the $EDITOR environment variable are defined.') args = shlex.split(editor) + repo.notes[path].files retcode = subprocess.call(args) if retcode != 0: raise HuskError('Editor had a non-successful exit. Nothing has been ' \ 'committed. To manually commit, use `husk commit`.')