summaryrefslogtreecommitdiff
path: root/inkstitch.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-05-19 14:41:50 -0400
committerGitHub <noreply@github.com>2018-05-19 14:41:50 -0400
commit9dadd836e2f09b0216f7b40c782e2b55bcc90dee (patch)
tree128b6f13ea682a8e5a033370ab2e13388801f100 /inkstitch.py
parentba7288d8fcd62678bd17d8fab01d0d488d9e21e8 (diff)
parent6fe417cd64090f028c0d07b799620eb94637bf33 (diff)
Merge pull request #163 from lexelby/lexelby-single-extension
single code entry point
Diffstat (limited to 'inkstitch.py')
-rw-r--r--inkstitch.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/inkstitch.py b/inkstitch.py
new file mode 100644
index 00000000..a9ce829e
--- /dev/null
+++ b/inkstitch.py
@@ -0,0 +1,32 @@
+import sys
+import traceback
+from argparse import ArgumentParser
+from lib.utils import save_stderr, restore_stderr
+from lib import extensions
+
+
+parser = ArgumentParser()
+parser.add_argument("--extension")
+my_args, remaining_args = parser.parse_known_args()
+
+extension_name = my_args.extension
+extension_class = getattr(extensions, extension_name.capitalize())
+extension = extension_class()
+
+exception = None
+
+save_stderr()
+try:
+ extension.affect(args=remaining_args)
+except (SystemExit, KeyboardInterrupt):
+ raise
+except Exception:
+ exception = traceback.format_exc()
+finally:
+ restore_stderr()
+
+if exception:
+ print >> sys.stderr, exception
+ sys.exit(1)
+else:
+ sys.exit(0)