add main HPI executable

This commit is contained in:
Dima Gerasimov 2020-05-14 22:55:58 +01:00 committed by karlicoss
parent 6235e6ffae
commit 647b6087dd
3 changed files with 32 additions and 0 deletions

30
my/__main__.py Normal file
View file

@ -0,0 +1,30 @@
class Modes:
HELLO = 'hello'
def parser():
from argparse import ArgumentParser
p = ArgumentParser('Human Programming Interface', epilog='''
Tool for HPI.
Work in progress, will be used for config management, troubleshooting & introspection
''')
sp = p.add_subparsers(dest='mode')
sp.add_parser(Modes.HELLO, help='TODO just a stub, remove later')
return p
def main():
p = parser()
args = p.parse_args()
mode = args.mode
if mode == Modes.HELLO:
print('hi')
else:
import sys
p.print_usage()
sys.exit(1)
if __name__ == '__main__':
main()

View file

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

View file

@ -17,6 +17,7 @@ commands =
# TODO add; once I figure out porg depdencency?? tests/config.py
# TODO run demo.py? just make sure with_my is a bit cleverer?
# TODO e.g. under CI, rely on installing
hpi hello
[testenv:demo]