summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2015-08-28 13:53:08 +0200
committermakefu <github@syntax-fehler.de>2015-08-28 13:53:08 +0200
commita12e24ae318b5a12f91e81273de9ac1b08bde110 (patch)
treec2188c57c9fdc2572974f42edcf620018f024d38
parent4b6a54f8bff3015d2f6e9cd0ee7cc2a2f0bc528a (diff)
Reaktor: add new core, parse args with docopt instead of sys.argv
-rwxr-xr-xReaktor/index7
-rwxr-xr-xReaktor/reaktor/core.py30
-rw-r--r--Reaktor/setup.py3
3 files changed, 27 insertions, 13 deletions
diff --git a/Reaktor/index b/Reaktor/index
deleted file mode 100755
index fc59cd73..00000000
--- a/Reaktor/index
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /bin/sh
-set -euf
-
-# cd //Reaktor
-cd $(dirname $(readlink -f $0))
-
-exec IRC/index "$@"
diff --git a/Reaktor/reaktor/core.py b/Reaktor/reaktor/core.py
index 327d120a..e6250df9 100755
--- a/Reaktor/reaktor/core.py
+++ b/Reaktor/reaktor/core.py
@@ -1,16 +1,30 @@
#!/usr/bin/env python3
+""" usage:
+ reaktor (get-config|run) [CONFIG]
+
+ `get-config` writes the reaktor configuration to stdout
+ if CONFIG is not given it will write the
+ reaktor default config.
+
+ use this for creating your own config
+
+
+"""
import os
from reaktor.ircasy import asybot
from asyncore import loop
+import reaktor
from reaktor.translate_colors import translate_colors
import shlex
from re import split, search, match
+from os.path import dirname
-default_config = './config.py'
+default_config = dirname(reaktor.__file__)+'/config.py'
from reaktor.getconf import make_getconf
import logging,logging.handlers
log = logging.getLogger('Reaktor')
+
#hdlr = logging.handlers.SysLogHandler(address='/dev/log', facility=logging.handlers.SysLogHandler.LOG_DAEMON)
#formatter = logging.Formatter( '%(filename)s: %(levelname)s: %(message)s')
#hdlr.setFormatter(formatter)
@@ -141,13 +155,21 @@ class Reaktor(asybot):
def main():
import sys
- conf = sys.argv[1] if len(sys.argv) == 2 else default_config
+ from docopt import docopt
+ from docopt import docopt
+ args = docopt(__doc__)
+ conf = args['CONFIG'] if args['CONFIG'] else default_config
getconf = make_getconf(conf)
logging.basicConfig(level = logging.DEBUG if getconf('debug') else
logging.INFO)
log.debug("Debug enabled")
- Reaktor(conf,getconf)
- loop()
+
+ if args['run']:
+ Reaktor(conf,getconf)
+ loop()
+ elif args['get-config']:
+ print(open(conf).read())
if __name__ == "__main__":
main()
+
diff --git a/Reaktor/setup.py b/Reaktor/setup.py
index ab26428a..959d4c7c 100644
--- a/Reaktor/setup.py
+++ b/Reaktor/setup.py
@@ -13,7 +13,7 @@ setup(
author='krebs',
author_email='spam@krebsco.de',
-
+ install_requires = [ 'docopt' ],
packages=['reaktor'],
# optional non-python Deps:
# whatweb in path for 'whatweb'
@@ -27,7 +27,6 @@ setup(
]
},
- install_requires= [ ],
classifiers=[
"Intended Audience :: Developers",
"Natural Language :: English",