aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.mailmap3
-rw-r--r--Pipfile2
-rw-r--r--docs/source/conf.py2
-rw-r--r--docs/source/configuration.rst4
-rw-r--r--docs/source/nncli.1.rst32
-rw-r--r--nncli/__init__.py2
-rw-r--r--nncli/cli.py2
-rw-r--r--nncli/clipboard.py15
-rw-r--r--nncli/config.py9
-rw-r--r--nncli/notes_db.py6
-rw-r--r--nncli/utils.py3
-rw-r--r--tox.ini2
12 files changed, 66 insertions, 16 deletions
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000..842d9e8
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,3 @@
+Samuel Walladge <samuel@swalladge.id.au> <swalladge@users.noreply.github.com>
+Samuel Walladge <samuel@swalladge.id.au> <swalladge@gmail.com>
+Shawn Axsom <shawn.axsom@rooksecurity.com> <axs221@gmail.com>
diff --git a/Pipfile b/Pipfile
index 0b10b94..d7ed55f 100644
--- a/Pipfile
+++ b/Pipfile
@@ -10,7 +10,7 @@ urwid = "*"
click = "*"
[dev-packages]
-pytest = "*"
+pytest = ">=5.2,<5.3"
pytest-cov = "*"
pytest-mock = "*"
pylint = "*"
diff --git a/docs/source/conf.py b/docs/source/conf.py
index eddb6a3..8ca6b32 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -20,7 +20,7 @@ import nncli
# -- Project information -----------------------------------------------------
project = 'nncli'
-copyright = '2018, Daniel Moch'
+copyright = '2018-2019, Daniel Moch'
author = 'Daniel Moch'
# The short X.Y version
diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst
index 94571ad..6836e32 100644
--- a/docs/source/configuration.rst
+++ b/docs/source/configuration.rst
@@ -147,8 +147,8 @@ General Options
values ``{fname}`` and ``{line}`` can be used to specify respectively
the file name and line number to pass to the command.
- Optional. Default value: ``$EDITOR`` if defined in the user's
- environment, else ``vim {fname} +{line}``.
+ Optional. Default value: ``$VISUAL`` or ``$EDITOR`` if defined in the
+ user's environment (preferring ``$VISUAL``), else ``vim {fname} +{line}``.
.. confval:: cfg_pager
diff --git a/docs/source/nncli.1.rst b/docs/source/nncli.1.rst
new file mode 100644
index 0000000..c38d649
--- /dev/null
+++ b/docs/source/nncli.1.rst
@@ -0,0 +1,32 @@
+nncli - NextCloud Notes Command Line Interface
+==============================================
+
+Synopsis
+--------
+
+**nncli** [*options*] *command* [*args*]...
+
+Description
+-----------
+
+:program:`nncli` gives you access to your NextCloud notes account via
+the command line. You can access your notes via a customizable console
+GUI that implements vi-like keybinds or via a simple, scriptable command
+line interface.
+
+Notes can be viewed/created/edited in *both an* **online** *and*
+**offline** *mode*. All changes are saved to a local cache on disk and
+automatically sync'ed when nncli is brought online.
+
+Options
+-------
+
+.. include:: usage.rst
+
+Environment Variables
+---------------------
+
+See also
+--------
+
+:manpage:`nncli.config(5)`
diff --git a/nncli/__init__.py b/nncli/__init__.py
index 2765848..80704cf 100644
--- a/nncli/__init__.py
+++ b/nncli/__init__.py
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
"""NextCloud Notes Command Line Interface"""
-__version__ = '0.3.4'
+__version__ = '0.3.5'
diff --git a/nncli/cli.py b/nncli/cli.py
index cd7f2e1..91d0eb8 100644
--- a/nncli/cli.py
+++ b/nncli/cli.py
@@ -194,7 +194,7 @@ def json_import(nncli, from_stdin):
@click.command(short_help="Add a new note.")
@click.option('-t', '--title', help="Specify the title of note for create.")
-@click.argument('from_stdin', metavar='[-]', type=STDIN_FLAG)
+@click.argument('from_stdin', metavar='[-]', type=STDIN_FLAG, required=False)
@click.pass_obj
def create(nncli, title, from_stdin):
"""
diff --git a/nncli/clipboard.py b/nncli/clipboard.py
index cb4ba41..14dbcdb 100644
--- a/nncli/clipboard.py
+++ b/nncli/clipboard.py
@@ -2,7 +2,7 @@
"""clipboard module"""
import os
import subprocess
-from subprocess import CalledProcessError
+from subprocess import CalledProcessError, DEVNULL
class Clipboard:
"""Class implements copying note content to the clipboard"""
@@ -14,17 +14,26 @@ class Clipboard:
"""Defines the copy command based on the contents of $PATH"""
try:
- subprocess.check_output(['which', 'xsel'])
+ subprocess.check_call(['which', 'xsel'], stdout=DEVNULL, \
+ stderr=DEVNULL)
return 'echo "%s" | xsel -ib'
except CalledProcessError:
pass
try:
- subprocess.check_output(['which', 'pbcopy'])
+ subprocess.check_call(['which', 'pbcopy'], stdout=DEVNULL, \
+ stderr=DEVNULL)
return 'echo "%s" | pbcopy'
except CalledProcessError:
pass
+ try:
+ subprocess.check_call(['which', 'xclip'], stdout=DEVNULL, \
+ stderr=DEVNULL)
+ return 'echo "%s" | xclip -selection clipboard'
+ except CalledProcessError:
+ pass
+
return None
def copy(self, text):
diff --git a/nncli/config.py b/nncli/config.py
index 0e97faf..62b84a2 100644
--- a/nncli/config.py
+++ b/nncli/config.py
@@ -37,8 +37,6 @@ class Config:
'cfg_format_strftime' : '%Y/%m/%d',
'cfg_format_note_title' : '[%D] %F %-N %T',
'cfg_status_bar' : 'yes',
- 'cfg_editor' : os.environ['EDITOR'] \
- if 'EDITOR' in os.environ else 'vim {fname} +{line}',
'cfg_pager' : os.environ['PAGER'] \
if 'PAGER' in os.environ else 'less -c',
'cfg_max_logs' : '5',
@@ -132,6 +130,13 @@ class Config:
'clr_help_descr_bg' : 'default'
}
+ if 'VISUAL' in os.environ:
+ defaults['cfg_editor'] = os.environ['VISUAL']
+ elif 'EDITOR' in os.environ:
+ defaults['cfg_editor'] = os.environ['EDITOR']
+ else:
+ defaults['cfg_editor'] = 'vim {fname} +{line}'
+
parser = configparser.ConfigParser(defaults)
if custom_file is not None:
parser.read([custom_file])
diff --git a/nncli/notes_db.py b/nncli/notes_db.py
index f452546..c995a16 100644
--- a/nncli/notes_db.py
+++ b/nncli/notes_db.py
@@ -83,7 +83,7 @@ class NotesDB():
"""Set the update_view method"""
self.update_view = update_view
- def _filtered_notes_sort(self, filtered_notes, sort_mode='date'):
+ def filtered_notes_sort(self, filtered_notes, sort_mode='date'):
"""Sort filtered note set"""
if sort_mode == 'date':
if self.config.get_config('favorite_ontop') == 'yes':
@@ -124,7 +124,7 @@ class NotesDB():
filtered_notes, match_regexp, active_notes = \
self._filter_notes_regex(search_string)
- self._filtered_notes_sort(filtered_notes, sort_mode)
+ self.filtered_notes_sort(filtered_notes, sort_mode)
return filtered_notes, match_regexp, active_notes
@@ -466,7 +466,7 @@ class NotesDB():
# 1. for any note changed locally, including new notes:
# save note to server, update note with response
- for _, local_key in enumerate(self.notes.keys()):
+ for _, local_key in enumerate(list(self.notes.keys())):
note = self.notes[local_key]
if not note.get('id') or \
diff --git a/nncli/utils.py b/nncli/utils.py
index e043622..50399ed 100644
--- a/nncli/utils.py
+++ b/nncli/utils.py
@@ -41,8 +41,9 @@ def exec_cmd_on_note(note, config, gui, logger, cmd=None, raw=False):
)
fname = temp.tempfile_name(tfile)
+
+ focus_position = 0
if config.state.do_gui:
- focus_position = 0
try:
focus_position = gui.gui_body_get().focus_position
except IndexError:
diff --git a/tox.ini b/tox.ini
index 9a6499b..d4f3873 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py34, py35, py36, py37, pylint, coverage
+envlist = py34, py35, py36, py37, py38, pylint, coverage
skipsdist = True
[testenv:pylint]