2021-10-09 18:50:43 +02:00
|
|
|
# standard imports
|
|
|
|
import os
|
|
|
|
import logging
|
|
|
|
import argparse
|
|
|
|
import sys
|
|
|
|
import importlib
|
|
|
|
|
|
|
|
# external imports
|
|
|
|
import cic.cmd.init as cmd_init
|
2021-10-09 20:37:54 +02:00
|
|
|
import cic.cmd.show as cmd_show
|
2021-10-09 21:04:11 +02:00
|
|
|
import cic.cmd.export as cmd_export
|
2021-10-09 18:50:43 +02:00
|
|
|
|
|
|
|
logging.basicConfig(level=logging.WARNING)
|
|
|
|
logg = logging.getLogger()
|
|
|
|
|
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
data_dir = os.path.join(script_dir, '..', 'data')
|
|
|
|
schema_dir = os.path.join(script_dir, '..', 'schema')
|
|
|
|
|
|
|
|
argparser = argparse.ArgumentParser(description='CIC cli tool for generating and publishing tokens')
|
|
|
|
argparser.add_argument('-v', help='be verbose', action='store_true')
|
|
|
|
argparser.add_argument('-vv', help='be more verbose', action='store_true')
|
|
|
|
|
|
|
|
sub = argparser.add_subparsers()
|
|
|
|
sub.dest = 'command'
|
|
|
|
sub_init = sub.add_parser('init', help='initialize new cic data directory')
|
|
|
|
cmd_init.process_args(sub_init)
|
2021-10-09 20:37:54 +02:00
|
|
|
sub_show = sub.add_parser('show', help='display summary of current state of cic data directory')
|
|
|
|
cmd_show.process_args(sub_show)
|
2021-10-09 21:04:11 +02:00
|
|
|
sub_export = sub.add_parser('export', help='export cic data directory state to a specified target')
|
|
|
|
cmd_export.process_args(sub_export)
|
2021-10-09 18:50:43 +02:00
|
|
|
|
|
|
|
args = argparser.parse_args(sys.argv[1:])
|
|
|
|
|
|
|
|
if args.v == True:
|
|
|
|
logging.getLogger().setLevel(logging.INFO)
|
|
|
|
elif args.vv == True:
|
|
|
|
logging.getLogger().setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
if args.command == None:
|
|
|
|
logg.critical('Subcommand missing')
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
modname = 'cic.cmd.{}'.format(args.command)
|
|
|
|
logg.debug('using module {}'.format(modname))
|
|
|
|
cmd_mod = importlib.import_module(modname)
|
|
|
|
|
|
|
|
config = None
|
|
|
|
|
|
|
|
def main():
|
2021-10-09 20:37:54 +02:00
|
|
|
#try:
|
|
|
|
cmd_mod.execute(config, args)
|
|
|
|
#except ValueError as e:
|
|
|
|
# logg.error('{}'.format(e))
|
|
|
|
# sys.exit(1)
|
2021-10-09 18:50:43 +02:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|