boxespy/scripts/boxes

41 lines
840 B
Plaintext
Raw Normal View History

2016-03-23 22:15:34 +01:00
#!/usr/bin/python3
import argparse
import os
import sys
from pprint import pprint
try:
import boxes
except ImportError:
sys.path.append(os.path.dirname(__file__) + "/..")
import boxes
import boxes.generators
2016-03-23 22:15:34 +01:00
def printusage():
print("""Usage:
boxes [NAME] [options]
--list list possible names
--help show help for given NAME
""")
def main():
modules = boxes.generators.getAllBoxGenerators()
2016-03-23 22:15:34 +01:00
if len(sys.argv) == 1:
printusage()
elif sys.argv[1] in modules:
name = sys.argv[1]
sys.argv[0] = "%s %s" % (sys.argv[0], sys.argv[1])
del sys.argv[1]
modules[name].main()
elif sys.argv[1] == '--list':
print("Available generators:")
for name in sorted(modules):
print(" * ", name)
else:
print("unknown sub command")
2016-03-23 22:15:34 +01:00
main()