aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md46
-rw-r--r--setup.cfg8
-rw-r--r--wikijscmd/__init__.py11
-rw-r--r--wikijscmd/__main__.py6
-rw-r--r--[-rwxr-xr-x]wikijscmd/app.py (renamed from wikijscmd/cli.py)9
-rw-r--r--[-rwxr-xr-x]wikijscmd/tui.py (renamed from wikijscmd/ncurses.py)15
6 files changed, 41 insertions, 54 deletions
diff --git a/README.md b/README.md
index 3dfb013..c283225 100644
--- a/README.md
+++ b/README.md
@@ -3,13 +3,28 @@
A client to use wiki.js over the command line. Supports creating, editing,
and viewing pages, and viewing the wiki file tree.
+## Installation
+
+Install the module: `python3 -m pip install wikijscmd`
+
+Create a file `/etc/wikijscmd/config.ini` with the following information:
+```
+[wiki]
+key=YOUR_KEY_HERE
+url=YOUR_GRAPHQL_ENDPOINT_HERE
+```
+The key is provided via the admin panel under the API access tab. The URL
+for wiki.js is typically the URL of your wiki with the path `/graphql`. For
+example, if your wiki is at `wiki.example.com`, the url field should be set to
+`https://wiki.example.com/graphql`.
+
## Usage
wikijscmd supports the following commands:
### create PATH TITLE CONTENT?
-creates a page with the given page, title, and content. Content is optional,
-if none is provided, then an editor will open based on the VISUAL or EDITOR
-variable.
+creates a page with the given page, title, and content. Content is optional,
+if none is provided, then an editor will open based on the VISUAL or EDITOR
+variable.
### edit (PATH|ID)
opens a page in the editor based on VISUAL or EDITOR variables for the given
@@ -33,31 +48,6 @@ command `create 1970/01/01 "Janurary 1"`.
### move (PATH|ID) DEST\_PATH
Moves a page identified by the path or ID given to the destination path.
-## Installation
-Clone the repository or download the source code.
-
-Install python3, and pip for python3 for your system.
-
-Install the dependencies
-`pip3 install -r requirements.txt`
-
-Create a file `/etc/wikijscmd/config.ini` with the following information:
-```
-[wiki]
-key=YOUR_KEY_HERE
-url=YOUR_GRAPHQL_ENDPOINT_HERE
-```
-The key is provided via the admin panel under the API access tab. The URL
-for wiki.js is typically the URL of your wiki with the path `/graphql`. For
-example, if your wiki is at `wiki.example.com`, the url field should be set to
-`https://wiki.example.com/graphql`.
-
-Run `main.py` in order to use the program.
-
-Example uses:
-- Create a page `./main.py create 2021/02/26 "February 26"`
-- Edit a page `./main.py edit 2021/02/26`
-
## Ncurses TUI
A ncurses TUI beta client also is provided, though it is still a work in
progress. It is run through the file `ncurses.py`
diff --git a/setup.cfg b/setup.cfg
index 58f4a0d..5754d69 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,8 +1,8 @@
[metadata]
name = wikijscmd-markpowers
-version = 0.0.1
+version = 0.1.0
author = Mark Powers
-author_email = author@example.com
+author_email = mark@marks.kitchen
description = A command line interface client for wiki.js
long_description = file: README.md
long_description_content_type = text/markdown
@@ -23,6 +23,6 @@ python_requires = >=3.6
[options.packages.find]
where=wikijscmd
-[entry_points]
+[options.entry_points]
console_scripts =
- wikijscmd = wikijscmd.cli:cli()
+ wikijscmd = wikijscmd.cli:cli
diff --git a/wikijscmd/__init__.py b/wikijscmd/__init__.py
index 8f45ae2..e69de29 100644
--- a/wikijscmd/__init__.py
+++ b/wikijscmd/__init__.py
@@ -1,11 +0,0 @@
-from wikijscmd import cli
-from wikijscmd import ncurses
-
-def main():
- cli.cli()
-
-def tui():
- try:
- ncurses.wrapper(m)
- except Exception as e:
- raise e
diff --git a/wikijscmd/__main__.py b/wikijscmd/__main__.py
index 02ddab3..267af9f 100644
--- a/wikijscmd/__main__.py
+++ b/wikijscmd/__main__.py
@@ -1,4 +1,6 @@
-import wikijscmd
+import sys
+
+from . import app
if __name__ == '__main__':
- wikijscmd.main()
+ app.main()
diff --git a/wikijscmd/cli.py b/wikijscmd/app.py
index 2847e40..c16a446 100755..100644
--- a/wikijscmd/cli.py
+++ b/wikijscmd/app.py
@@ -5,8 +5,9 @@ import argparse
from wikijscmd.config import config
from wikijscmd.commands import create, edit, single, tree, today, move, fill_in_pages
+from wikijscmd.tui import tui
-def cli():
+def main():
parser = argparse.ArgumentParser("wikijscmd")
parser.set_defaults(command=None)
subparsers = parser.add_subparsers()
@@ -40,6 +41,9 @@ def cli():
parser_journal = subparsers.add_parser("journal", help="create journal pages")
parser_journal.set_defaults(command=fill_in_pages)
+ parser_tui = subparsers.add_parser("tui", help="lauch a ncurses interface")
+ parser_tui.set_defaults(command=tui)
+
args = vars(parser.parse_args())
callback = args["command"]
if callback is None:
@@ -47,6 +51,3 @@ def cli():
else:
del args["command"]
callback(**args)
-
-if __name__ == "__main__":
- main()
diff --git a/wikijscmd/ncurses.py b/wikijscmd/tui.py
index ecc145f..16232bb 100755..100644
--- a/wikijscmd/ncurses.py
+++ b/wikijscmd/tui.py
@@ -3,7 +3,7 @@
import curses
from curses import wrapper
-from wikijscmd import util
+from wikijscmd import util, commands
def pager(stdscr, lst):
'''
@@ -87,17 +87,22 @@ def m(stdscr):
ret = pager(stdscr, [x["path"] + "\t" + x["title"] for x in items])
if ret["action"] == "select":
selected = items[ret["index"]]
- ret = pager(stdscr, main.get_single_page(selected["path"])["content"].split("\n"))
+ ret = pager(stdscr, util.get_single_page(selected["path"])["content"].split("\n"))
elif ret["action"] == "edit":
selected = items[ret["index"]]
- main.edit({"path":selected["path"], "save": True})
+ commands.edit(selected["path"], True)
elif ret["action"] == "create":
stdscr.clear()
title = enter_value(stdscr, "Enter title: ", 0)
path = enter_value(stdscr, "Enter path: ", 1)
- main.create({"path": path, "title": title})
+ commands.create(path, title)
elif ret["action"] == "today":
- main.today({})
+ commands.today()
else:
break
+def tui():
+ try:
+ wrapper(m)
+ except Exception as e:
+ raise e