Diff
from v0.3.4 to v0.3.5
Diffstat
.mailmap | 3 +++
Pipfile | 2 +-
docs/source/conf.py | 2 +-
docs/source/configuration.rst | 4 ++--
docs/source/nncli.1.rst | 32 ++++++++++++++++++++++++++++++++
nncli/__init__.py | 2 +-
nncli/cli.py | 2 +-
nncli/clipboard.py | 15 ++++++++++++---
nncli/config.py | 9 +++++++--
nncli/notes_db.py | 6 +++---
nncli/utils.py | 3 ++-
tox.ini | 2 +-
.mailmap (created)
|
1 |
+Samuel Walladge <samuel@swalladge.id.au> <swalladge@users.noreply.github.com> |
|
2 |
+Samuel Walladge <samuel@swalladge.id.au> <swalladge@gmail.com> |
|
3 |
+Shawn Axsom <shawn.axsom@rooksecurity.com> <axs221@gmail.com> |
Pipfile
10 |
10 |
click = "*" |
11 |
11 |
|
12 |
12 |
[dev-packages] |
13 |
|
-pytest = "*" |
|
13 |
+pytest = ">=5.2,<5.3" |
14 |
14 |
pytest-cov = "*" |
15 |
15 |
pytest-mock = "*" |
16 |
16 |
pylint = "*" |
docs/source/conf.py
20 |
20 |
# -- Project information ----------------------------------------------------- |
21 |
21 |
|
22 |
22 |
project = 'nncli' |
23 |
|
-copyright = '2018, Daniel Moch' |
|
23 |
+copyright = '2018-2019, Daniel Moch' |
24 |
24 |
author = 'Daniel Moch' |
25 |
25 |
|
26 |
26 |
# The short X.Y version |
docs/source/configuration.rst
147 |
147 |
values ``{fname}`` and ``{line}`` can be used to specify respectively |
148 |
148 |
the file name and line number to pass to the command. |
149 |
149 |
|
150 |
|
- Optional. Default value: ``$EDITOR`` if defined in the user's |
151 |
|
- environment, else ``vim {fname} +{line}``. |
|
150 |
+ Optional. Default value: ``$VISUAL`` or ``$EDITOR`` if defined in the |
|
151 |
+ user's environment (preferring ``$VISUAL``), else ``vim {fname} +{line}``. |
152 |
152 |
|
153 |
153 |
.. confval:: cfg_pager |
154 |
154 |
|
docs/source/nncli.1.rst (created)
|
1 |
+nncli - NextCloud Notes Command Line Interface |
|
2 |
+============================================== |
|
3 |
+ |
|
4 |
+Synopsis |
|
5 |
+-------- |
|
6 |
+ |
|
7 |
+**nncli** [*options*] *command* [*args*]... |
|
8 |
+ |
|
9 |
+Description |
|
10 |
+----------- |
|
11 |
+ |
|
12 |
+:program:`nncli` gives you access to your NextCloud notes account via |
|
13 |
+the command line. You can access your notes via a customizable console |
|
14 |
+GUI that implements vi-like keybinds or via a simple, scriptable command |
|
15 |
+line interface. |
|
16 |
+ |
|
17 |
+Notes can be viewed/created/edited in *both an* **online** *and* |
|
18 |
+**offline** *mode*. All changes are saved to a local cache on disk and |
|
19 |
+automatically sync'ed when nncli is brought online. |
|
20 |
+ |
|
21 |
+Options |
|
22 |
+------- |
|
23 |
+ |
|
24 |
+.. include:: usage.rst |
|
25 |
+ |
|
26 |
+Environment Variables |
|
27 |
+--------------------- |
|
28 |
+ |
|
29 |
+See also |
|
30 |
+-------- |
|
31 |
+ |
|
32 |
+:manpage:`nncli.config(5)` |
nncli/__init__.py
1 |
1 |
# -*- coding: utf-8 -*- |
2 |
2 |
"""NextCloud Notes Command Line Interface""" |
3 |
3 |
|
4 |
|
-__version__ = '0.3.4' |
|
4 |
+__version__ = '0.3.5' |
nncli/cli.py
194 |
194 |
|
195 |
195 |
@click.command(short_help="Add a new note.") |
196 |
196 |
@click.option('-t', '--title', help="Specify the title of note for create.") |
197 |
|
-@click.argument('from_stdin', metavar='[-]', type=STDIN_FLAG) |
|
197 |
+@click.argument('from_stdin', metavar='[-]', type=STDIN_FLAG, required=False) |
198 |
198 |
@click.pass_obj |
199 |
199 |
def create(nncli, title, from_stdin): |
200 |
200 |
""" |
nncli/clipboard.py
2 |
2 |
"""clipboard module""" |
3 |
3 |
import os |
4 |
4 |
import subprocess |
5 |
|
-from subprocess import CalledProcessError |
|
5 |
+from subprocess import CalledProcessError, DEVNULL |
6 |
6 |
|
7 |
7 |
class Clipboard: |
8 |
8 |
"""Class implements copying note content to the clipboard""" |
|
|
. . . |
14 |
14 |
"""Defines the copy command based on the contents of $PATH""" |
15 |
15 |
|
16 |
16 |
try: |
17 |
|
- subprocess.check_output(['which', 'xsel']) |
|
17 |
+ subprocess.check_call(['which', 'xsel'], stdout=DEVNULL, \ |
|
18 |
+ stderr=DEVNULL) |
18 |
19 |
return 'echo "%s" | xsel -ib' |
19 |
20 |
except CalledProcessError: |
20 |
21 |
pass |
21 |
22 |
|
22 |
23 |
try: |
23 |
|
- subprocess.check_output(['which', 'pbcopy']) |
|
24 |
+ subprocess.check_call(['which', 'pbcopy'], stdout=DEVNULL, \ |
|
25 |
+ stderr=DEVNULL) |
24 |
26 |
return 'echo "%s" | pbcopy' |
|
27 |
+ except CalledProcessError: |
|
28 |
+ pass |
|
29 |
+ |
|
30 |
+ try: |
|
31 |
+ subprocess.check_call(['which', 'xclip'], stdout=DEVNULL, \ |
|
32 |
+ stderr=DEVNULL) |
|
33 |
+ return 'echo "%s" | xclip -selection clipboard' |
25 |
34 |
except CalledProcessError: |
26 |
35 |
pass |
27 |
36 |
|
nncli/config.py
37 |
37 |
'cfg_format_strftime' : '%Y/%m/%d', |
38 |
38 |
'cfg_format_note_title' : '[%D] %F %-N %T', |
39 |
39 |
'cfg_status_bar' : 'yes', |
40 |
|
- 'cfg_editor' : os.environ['EDITOR'] \ |
41 |
|
- if 'EDITOR' in os.environ else 'vim {fname} +{line}', |
42 |
40 |
'cfg_pager' : os.environ['PAGER'] \ |
43 |
41 |
if 'PAGER' in os.environ else 'less -c', |
44 |
42 |
'cfg_max_logs' : '5', |
|
|
. . . |
131 |
129 |
'clr_help_descr_fg' : 'default', |
132 |
130 |
'clr_help_descr_bg' : 'default' |
133 |
131 |
} |
|
132 |
+ |
|
133 |
+ if 'VISUAL' in os.environ: |
|
134 |
+ defaults['cfg_editor'] = os.environ['VISUAL'] |
|
135 |
+ elif 'EDITOR' in os.environ: |
|
136 |
+ defaults['cfg_editor'] = os.environ['EDITOR'] |
|
137 |
+ else: |
|
138 |
+ defaults['cfg_editor'] = 'vim {fname} +{line}' |
134 |
139 |
|
135 |
140 |
parser = configparser.ConfigParser(defaults) |
136 |
141 |
if custom_file is not None: |
nncli/notes_db.py
83 |
83 |
"""Set the update_view method""" |
84 |
84 |
self.update_view = update_view |
85 |
85 |
|
86 |
|
- def _filtered_notes_sort(self, filtered_notes, sort_mode='date'): |
|
86 |
+ def filtered_notes_sort(self, filtered_notes, sort_mode='date'): |
87 |
87 |
"""Sort filtered note set""" |
88 |
88 |
if sort_mode == 'date': |
89 |
89 |
if self.config.get_config('favorite_ontop') == 'yes': |
|
|
. . . |
124 |
124 |
filtered_notes, match_regexp, active_notes = \ |
125 |
125 |
self._filter_notes_regex(search_string) |
126 |
126 |
|
127 |
|
- self._filtered_notes_sort(filtered_notes, sort_mode) |
|
127 |
+ self.filtered_notes_sort(filtered_notes, sort_mode) |
128 |
128 |
|
129 |
129 |
return filtered_notes, match_regexp, active_notes |
130 |
130 |
|
|
|
. . . |
466 |
466 |
|
467 |
467 |
# 1. for any note changed locally, including new notes: |
468 |
468 |
# save note to server, update note with response |
469 |
|
- for _, local_key in enumerate(self.notes.keys()): |
|
469 |
+ for _, local_key in enumerate(list(self.notes.keys())): |
470 |
470 |
note = self.notes[local_key] |
471 |
471 |
|
472 |
472 |
if not note.get('id') or \ |
nncli/utils.py
41 |
41 |
) |
42 |
42 |
fname = temp.tempfile_name(tfile) |
43 |
43 |
|
|
44 |
+ |
|
45 |
+ focus_position = 0 |
44 |
46 |
if config.state.do_gui: |
45 |
|
- focus_position = 0 |
46 |
47 |
try: |
47 |
48 |
focus_position = gui.gui_body_get().focus_position |
48 |
49 |
except IndexError: |
tox.ini
1 |
1 |
[tox] |
2 |
|
-envlist = py34, py35, py36, py37, pylint, coverage |
|
2 |
+envlist = py34, py35, py36, py37, py38, pylint, coverage |
3 |
3 |
skipsdist = True |
4 |
4 |
|
5 |
5 |
[testenv:pylint] |