Created
April 1, 2015 09:36
-
-
Save delhage/dcac645014170f1d61cf to your computer and use it in GitHub Desktop.
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
def parse_args(): | |
''' None -> None | |
Parse command line arguments and configuration | |
file values | |
''' | |
conf_dir = os.path.expanduser('~/.dockerreg') | |
user_conf_file = os.path.join(conf_dir, 'config') | |
config = SafeConfigParser() | |
config.read(user_conf_file) | |
options_table = [ | |
Option('-s','--server', action='store', | |
help='connect to this server', | |
default=config.get('registry','server')), | |
Option('-p','--port', action='store', | |
help='connect to this port', | |
default=config.get('registry','port')), | |
Option('-l','--list-repos', action='store', | |
help='list all repos'), | |
Option('-r','--repo', action='store', | |
help='repository'), | |
Option('--tags', action='store', | |
help='list tags, requires -r') | |
] | |
usage = 'usage: %prog [options] [command]' | |
parser = OptionParser(option_list=options_table, usage=usage) | |
(options, args) = parser.parse_args() | |
if not options.server: | |
print "try: " + sys.argv[0] + " --help" | |
sys.exit(2) | |
if not options.port: | |
print "try: "+sys.argv[0]+" --help" | |
sys.exit(2) | |
return options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment