From c5d960438cc111c5476b0261628b0ffcb1d25dbd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 8 Sep 2011 14:05:20 +0200 Subject: [PATCH] import parser from steven Signed-off-by: Nico Schottelius --- bin/cdist | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/bin/cdist b/bin/cdist index 594b5eea..72e95e29 100755 --- a/bin/cdist +++ b/bin/cdist @@ -201,3 +201,41 @@ if __name__ == "__main__": print(c.list_global_explorers()) c.cleanup() + +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import logging +# TODO: configure logging based on config and/or user given arguments +logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') +log = logging.getLogger() + +import argparse +import sys + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Some helpfull blabla') + parser.add_argument('host', nargs='+', help='one or more hosts to operate on') + parser.add_argument('-i', '--initial-manifest', + help='path to a cdist manifest or - to read from stdin', + dest='manifest', required=True) + parser.add_argument('-p', '--parallel', + help='operate on multiple hosts in parallel', + action='store_true', dest='parallel') + parser.add_argument('-s', '--sequential', + help='operate on multiple hosts sequentially', + action='store_false', dest='parallel') + parser.add_argument('-d', '--debug', help='set log level to debug', + action='store_true') + + args = parser.parse_args(sys.argv[1:]) + if args.debug: + logging.root.setLevel(logging.DEBUG) + log.debug('Look ma, now whe\'re showing debug messages') + + try: + print(args) + #import cdist + #sys.exit(cdist.main(args)) + except KeyboardInterrupt: + sys.exit(0)