Esempio n. 1
0
File: workon.py Progetto: husk/husk
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`."
        )
Esempio n. 2
0
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)
Esempio n. 3
0
File: add.py Progetto: husk/husk
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()
Esempio n. 4
0
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()
Esempio n. 5
0
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))
Esempio n. 6
0
File: info.py Progetto: husk/husk
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))
Esempio n. 7
0
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`.')