cli: move doctor to core, add doc

This commit is contained in:
Dima Gerasimov 2020-05-25 10:17:40 +01:00
parent dab29a44b5
commit 8019389ccb
4 changed files with 27 additions and 6 deletions

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -68,7 +68,7 @@ def main():
'dataclasses',
],
},
entry_points={'console_scripts': ['hpi=my.__main__:main']},
entry_points={'console_scripts': ['hpi=my.core.__main__:main']},
)