mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
Check the value of the --color argument
Make sure it's either `auto' (the default), `always' or `never'. If it does not match any of the values, raise a Docopt exception that causes it to print usage and exit. Tested: - $ sudo ./bootstrap-vz --color=invalid manifests/gce.manifest.yml Value of --color must be one of auto, always or never. Usage: bootstrap-vz [options] MANIFEST Signed-off-by: Filipe Brandenburger <filbranden@google.com>
This commit is contained in:
parent
84cf497c66
commit
1fe10207b8
1 changed files with 5 additions and 2 deletions
|
@ -34,7 +34,7 @@ def main():
|
|||
def get_opts():
|
||||
"""Creates an argument parser and returns the arguments it has parsed
|
||||
"""
|
||||
from docopt import docopt
|
||||
import docopt
|
||||
usage = """bootstrap-vz
|
||||
|
||||
Usage: bootstrap-vz [options] MANIFEST
|
||||
|
@ -49,7 +49,10 @@ Options:
|
|||
--debug Print debugging information
|
||||
-h, --help show this help
|
||||
"""
|
||||
return docopt(usage)
|
||||
opts = docopt.docopt(usage)
|
||||
if opts['--color'] not in ('auto', 'always', 'never'):
|
||||
raise docopt.DocoptExit('Value of --color must be one of auto, always or never.')
|
||||
return opts
|
||||
|
||||
|
||||
def setup_loggers(opts):
|
||||
|
|
Loading…
Add table
Reference in a new issue