Skip to content

Commit

Permalink
Update __main__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zeratax authored Feb 27, 2020
1 parent 59a30bb commit 145526b
Showing 1 changed file with 11 additions and 53 deletions.
64 changes: 11 additions & 53 deletions matrix_registration/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,62 +41,14 @@ def status_token(args):
# indent=4,
# default=str))
print(tokens.tokens)
<<<<<<< HEAD


parser = argparse.ArgumentParser(
description='a token based matrix registration app',
prog='python -m matrix_registration')
parser.add_argument('--config-path', default='config.yaml'
, help='specifies the config file to be used', metavar='PATH')

# subparser
subparsers = parser.add_subparsers(
help='sub-commands. for ex. \'gen -h\' ' +
'for additional help')

# api-parser
parser_a = subparsers.add_parser('api', help='start as api')
parser_a.set_defaults(func=run_api)

# generate-parser
parser_g = subparsers.add_parser('gen',
help='generate new token. ' +
'-o onetime, -e expire date')
parser_g.add_argument('-o', '--one-time', action='store_true',
help='make token one-time-useable')
parser_g.add_argument('-e', '--expire', type=str, default=None,
help='expire date: DD.MM.YYYY')
parser_g.set_defaults(func=generate_token)

# status-parser
parser_s = subparsers.add_parser('status',
help='view status or disable ' +
'token. -s status, -d disable, -l list')
parser_s.add_argument('-s', '--status', type=str, default=None,
help='token status')
parser_s.add_argument('-l', '--list', action='store_true',
help='list tokens')
parser_s.add_argument('-d', '--disable', type=str, default=None,
help='disable token')
parser_s.set_defaults(func=status_token)

args = parser.parse_args()

config.config = config.Config(args.config_path)
logging.config.dictConfig(config.config.logging)
tokens.tokens = tokens.Tokens()

logger = logging.getLogger(__name__)

logger.debug('called with args: %s' % args)
if 'func' in args:
args.func(args)
=======


def main():
parser = argparse.ArgumentParser(
description='a token based matrix registration app',
prog='python -m matrix_registration')
parser.add_argument('--config-path', default='config.yaml'
, help='specifies the config file to be used', metavar='PATH')

# subparser
subparsers = parser.add_subparsers(
Expand Down Expand Up @@ -130,10 +82,16 @@ def main():
parser_s.set_defaults(func=status_token)

args = parser.parse_args()

config.config = config.Config(args.config_path)
logging.config.dictConfig(config.config.logging)
tokens.tokens = tokens.Tokens()

logger = logging.getLogger(__name__)

logger.debug('called with args: %s' % args)
if 'func' in args:
args.func(args)

if __name__ == '__main__':
main()
>>>>>>> a6d2eb6... add main() function

0 comments on commit 145526b

Please sign in to comment.