From 90bdf0433672456653d2d3425b5c0689bb52135b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 13 Sep 2011 21:30:17 +0200 Subject: [PATCH] add epilog to parsers, make it look beautiful Signed-off-by: Nico Schottelius --- bin/cdist | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bin/cdist b/bin/cdist index ad5584af..5333cb3a 100755 --- a/bin/cdist +++ b/bin/cdist @@ -632,20 +632,20 @@ if __name__ == "__main__": # Construct parser others can reuse parser = {} # Options _all_ parsers have in common - parser['most'] = argparse.ArgumentParser(add_help=False, - epilog="Get cdist at http://www.nico.schottelius.org/software/cdist/") + parser['most'] = argparse.ArgumentParser(add_help=False) parser['most'].add_argument('-d', '--debug', help='Set log level to debug', action='store_true') - parser['most'].add_argument('-V', '--version', - help='Show version', action='version', - version='%(prog)s ' + VERSION) # Main subcommand parser - parser['main'] = argparse.ArgumentParser(description='cdist ' + VERSION, - parents=[parser['most']]) + parser['main'] = argparse.ArgumentParser(description='cdist ' + VERSION) + + parser['main'].add_argument('-V', '--version', + help='Show version', action='version', + version='%(prog)s ' + VERSION) parser['sub'] = parser['main'].add_subparsers() - parser['banner'] = parser['sub'].add_parser('banner') + parser['banner'] = parser['sub'].add_parser('banner', + add_help=False) parser['banner'].set_defaults(func=banner) parser['config'] = parser['sub'].add_parser('config', @@ -666,6 +666,9 @@ if __name__ == "__main__": action='store_false', dest='parallel') parser['config'].set_defaults(func=config) + for p in parser: + parser[p].epilog = "Get cdist at http://www.nico.schottelius.org/software/cdist/" + args = parser['main'].parse_args(sys.argv[1:]) # Most subcommands have --debug, so handle it here