diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | pyproject.toml | 16 | ||||
-rw-r--r-- | requirements.txt | 2 | ||||
-rw-r--r-- | setup.cfg | 28 | ||||
-rw-r--r-- | wikijscmd/__init__.py | 11 | ||||
-rw-r--r-- | wikijscmd/__main__.py | 4 | ||||
-rwxr-xr-x | wikijscmd/cli.py (renamed from main.py) | 6 | ||||
-rw-r--r-- | wikijscmd/commands.py (renamed from commands.py) | 4 | ||||
-rw-r--r-- | wikijscmd/config.py (renamed from config.py) | 2 | ||||
-rw-r--r-- | wikijscmd/custom_requests.py (renamed from custom_requests.py) | 2 | ||||
-rw-r--r-- | wikijscmd/graphql_queries.py (renamed from graphql_queries.py) | 2 | ||||
-rwxr-xr-x | wikijscmd/ncurses.py (renamed from ncurses.py) | 11 | ||||
-rw-r--r-- | wikijscmd/util.py (renamed from util.py) | 2 |
13 files changed, 73 insertions, 19 deletions
@@ -1,4 +1,4 @@ __pycache__/ config.ini -*.swp +dist/ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..44ab690 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[tool.poetry] +name = "wikijscmd" +version = "0.1.0" +description = "A command line interface (CLI) for wiki.js" +authors = ["Mark Powers <mark@marks.kitchen>"] +license = "GPL 3" + +[tool.poetry.dependencies] +python = "^3.8" +requests = "^2.26.0" + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 57db5b3..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -requests==2.25.1 - diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..58f4a0d --- /dev/null +++ b/setup.cfg @@ -0,0 +1,28 @@ +[metadata] +name = wikijscmd-markpowers +version = 0.0.1 +author = Mark Powers +author_email = author@example.com +description = A command line interface client for wiki.js +long_description = file: README.md +long_description_content_type = text/markdown +url = https://github.com/Mark-Powers/wikijscmd +project_urls = + Bug Tracker = https://github.com/Mark-Powers/wikijscmd/issues +classifiers = + Programming Language :: Python :: 3 + License :: OSI Approved :: MIT License + Operating System :: OS Independent + +[options] +package_dir = + = wikijscmd +packages = find: +python_requires = >=3.6 + +[options.packages.find] +where=wikijscmd + +[entry_points] +console_scripts = + wikijscmd = wikijscmd.cli:cli() diff --git a/wikijscmd/__init__.py b/wikijscmd/__init__.py new file mode 100644 index 0000000..8f45ae2 --- /dev/null +++ b/wikijscmd/__init__.py @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..02ddab3 --- /dev/null +++ b/wikijscmd/__main__.py @@ -0,0 +1,4 @@ +import wikijscmd + +if __name__ == '__main__': + wikijscmd.main() diff --git a/main.py b/wikijscmd/cli.py index c91fc1c..2847e40 100755 --- a/main.py +++ b/wikijscmd/cli.py @@ -3,10 +3,10 @@ import sys import argparse -from config import config -from commands import create, edit, single, tree, today, move, fill_in_pages +from wikijscmd.config import config +from wikijscmd.commands import create, edit, single, tree, today, move, fill_in_pages -def main(): +def cli(): parser = argparse.ArgumentParser("wikijscmd") parser.set_defaults(command=None) subparsers = parser.add_subparsers() diff --git a/commands.py b/wikijscmd/commands.py index 4d941cf..86cfe7b 100644 --- a/commands.py +++ b/wikijscmd/commands.py @@ -1,8 +1,8 @@ import sys -import graphql_queries +from wikijscmd import graphql_queries from datetime import datetime, timedelta -from util import clean_filename, get_tree, open_editor, get_single_page, print_item, args_for_date +from wikijscmd.util import clean_filename, get_tree, open_editor, get_single_page, print_item, args_for_date def create(path, title, content=None): page = get_single_page(path) diff --git a/config.py b/wikijscmd/config.py index b42ca6e..f6c9b7e 100644 --- a/config.py +++ b/wikijscmd/config.py @@ -1,6 +1,6 @@ import os from configparser import ConfigParser -config_path = os.path.join(os.path.dirname(__file__), "config.ini") +config_path = "/etc/wikijscmd/config.ini" config = ConfigParser() config.read(config_path) diff --git a/custom_requests.py b/wikijscmd/custom_requests.py index 65673cf..bc9b16e 100644 --- a/custom_requests.py +++ b/wikijscmd/custom_requests.py @@ -1,7 +1,7 @@ import requests import sys import json -from config import config +from wikijscmd.config import config def handle_errors(r): error = False diff --git a/graphql_queries.py b/wikijscmd/graphql_queries.py index db23f23..32aaaef 100644 --- a/graphql_queries.py +++ b/wikijscmd/graphql_queries.py @@ -1,4 +1,4 @@ -import custom_requests +from wikijscmd import custom_requests def get_single_page(page_id): query = 'query ($id: Int!) {\npages {\nsingle (id: $id) {\nid\npath\ntitle\ncontent\n}\n}\n}' diff --git a/ncurses.py b/wikijscmd/ncurses.py index 073ad50..ecc145f 100755 --- a/ncurses.py +++ b/wikijscmd/ncurses.py @@ -1,8 +1,10 @@ #!/usr/bin/env python3 -import main + import curses from curses import wrapper +from wikijscmd import util + def pager(stdscr, lst): ''' Runs a pager for each string item in lst @@ -80,7 +82,7 @@ def m(stdscr): """ The main method for the ncurses wrapper """ - items = main.get_tree("") + items = util.get_tree("") while True: ret = pager(stdscr, [x["path"] + "\t" + x["title"] for x in items]) if ret["action"] == "select": @@ -99,8 +101,3 @@ def m(stdscr): else: break -# Run the ncurses wrapper -try: - wrapper(m) -except Exception as e: - raise e diff --git a/util.py b/wikijscmd/util.py index a3b9fbd..86f2eb4 100644 --- a/util.py +++ b/wikijscmd/util.py @@ -1,4 +1,4 @@ -import graphql_queries +from wikijscmd import graphql_queries import subprocess import re import os |