Last active
June 9, 2017 12:04
-
-
Save spiette/7c99777b342d6bacdc1ea2ed975024af to your computer and use it in GitHub Desktop.
WIP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
import logging | |
import os | |
import sys | |
import argcomplete | |
VERSION = '0.1.0' | |
PROGRAM_NAME = os.path.basename(sys.argv[0])[:-3] | |
def parseargs(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--version', | |
action='version', | |
version=VERSION) | |
parser.add_argument('-v', '--verbose', | |
action='store_true') | |
parser.add_argument('-d', '--debug', | |
action='store_true') | |
subparsers = parser.add_subparsers() | |
# dependencies | |
dependencies_parser = subparsers.add_parser('dependencies') | |
action_group = dependencies_parser.add_mutually_exclusive_group() | |
action_group.add_argument( | |
'--install', | |
action='store_true', | |
help='install cloud dependencies in roles/<cloud>') | |
action_group.add_argument( | |
'--upgrade', | |
action='store_true', | |
help='upgrade cloud dependencies in roles/<cloud>') | |
dependencies_parser.add_argument( | |
'--devel', action='store_true', | |
help='install/upgrade git dependencies in roles/devel/<cloud>') | |
dependencies_parser.add_argument( | |
'--cloud', | |
required=True, | |
help='speficify which cloud dependencies in roles/<cloud>') | |
# play | |
dependencies_parser = subparsers.add_parser('play') | |
dependencies_parser.add_argument( | |
'--cloud', | |
required=True, | |
help='speficify which cloud dependencies in roles/<cloud>') | |
# at this point, we cannot add --check --diff | |
dependencies_parser.add_argument( | |
'ansibleargs', | |
nargs='*', | |
help='ansible-playbook arguments') | |
args = parser.parse_args() | |
argcomplete.autocomplete(parser) | |
return args | |
if __name__ == '__main__': | |
args = parseargs() | |
if args.verbose: | |
logging.basicConfig(level=logging.INFO) | |
if args.debug: | |
logging.basicConfig(level=logging.DEBUG) | |
logging.debug(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment