From 8019389ccb369e9c71987ad6a7c2295d6e9b312e Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 25 May 2020 10:17:40 +0100 Subject: [PATCH] cli: move doctor to core, add doc --- doc/MODULES.org | 2 ++ doc/SETUP.org | 11 +++++++++++ my/{ => core}/__main__.py | 18 +++++++++++++----- setup.py | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) rename my/{ => core}/__main__.py (89%) diff --git a/doc/MODULES.org b/doc/MODULES.org index e26d439..8632543 100644 --- a/doc/MODULES.org +++ b/doc/MODULES.org @@ -1,6 +1,8 @@ This file is an overview of *documented* modules. There are many more, see [[file:../README.org::#whats-inside]["What's inside"]] for the full list of modules, I'm progressively working on documenting them. +If you have some issues with the setup, see [[file:SETUP.org::#troubleshooting]["Troubleshooting"]]. + * TOC :PROPERTIES: :TOC: :include all diff --git a/doc/SETUP.org b/doc/SETUP.org index 73e2a82..afc9b30 100644 --- a/doc/SETUP.org +++ b/doc/SETUP.org @@ -19,6 +19,7 @@ You'd be really helping me, I want to make the setup as straightforward as possi - [[#setting-up-modules][Setting up modules]] - [[#private-configuration-myconfig][private configuration (my.config)]] - [[#module-dependencies][module dependencies]] +- [[#troubleshooting][Troubleshooting]] - [[#usage-examples][Usage examples]] - [[#end-to-end-roam-research-setup][End-to-end Roam Research setup]] - [[#polar][Polar]] @@ -220,6 +221,16 @@ Dependencies are different for specific modules you're planning to use, so it's Generally you can just try using the module and then install missing packages via ~pip3 install --user~, should be fairly straightforward. + +* Troubleshooting +# todo replace with_my with it?? + +HPI comes with a command line tool that can help you detect potential issues. Run: + +: hpi doctor + +If you have any ideas on how to improve it, please let me know! + * Usage examples If you run your script with ~with_my~ wrapper, you'd have ~my~ in ~PYTHONPATH~ which gives you access to your data from within the script. diff --git a/my/__main__.py b/my/core/__main__.py similarity index 89% rename from my/__main__.py rename to my/core/__main__.py index b465669..c973afe 100644 --- a/my/__main__.py +++ b/my/core/__main__.py @@ -4,17 +4,18 @@ import sys from subprocess import check_call, run, PIPE import traceback -from my.core import LazyLogger +from . import LazyLogger log = LazyLogger('HPI cli') class Modes: HELLO = 'hello' CONFIG = 'config' + DOCTOR = 'doctor' def run_mypy(pkg): - from my.core.init import get_mycfg_dir + from .init import get_mycfg_dir mycfg_dir = get_mycfg_dir() # todo ugh. not sure how to extract it from pkg? @@ -79,6 +80,10 @@ def config_check(args): sys.stderr.write(indent(mres.stdout.decode('utf8'))) +def doctor(args): + config_check(args) + + def hello(args): print('Hello') @@ -94,11 +99,14 @@ Work in progress, will be used for config management, troubleshooting & introspe hp = sp.add_parser(Modes.HELLO , help='TODO just a stub, remove later') hp.set_defaults(func=hello) + dp = sp.add_parser(Modes.DOCTOR, help='Run various checks') + dp.set_defaults(func=doctor) + cp = sp.add_parser(Modes.CONFIG, help='Work with configuration') scp = cp.add_subparsers(dest='mode') - if True: - ccp = scp.add_parser('check', help='Check config') - ccp.set_defaults(func=config_check) + # if True: + # ccp = scp.add_parser('check', help='Check config') + # ccp.set_defaults(func=config_check) return p diff --git a/setup.py b/setup.py index b68d77f..f2c2b03 100644 --- a/setup.py +++ b/setup.py @@ -68,7 +68,7 @@ def main(): 'dataclasses', ], }, - entry_points={'console_scripts': ['hpi=my.__main__:main']}, + entry_points={'console_scripts': ['hpi=my.core.__main__:main']}, )