def get_value(self, arguments, fallback=None):
import os
import os.path
import click
try:
path = self._locate_value(arguments, fallback=fallback)
# TODO: do we want a --force like flag?
if os.path.exists(path):
click.secho("Error: --%s directory already exists, won't "
"overwrite." % self.cli_name, err=True, fg='red',
bold=True)
ctx = click.get_current_context()
ctx.exit(1)
os.makedirs(path)
def fallback_(name, cli_name):
return os.path.join(path, name)
return fallback_
except ValueNotFoundException:
# Always fail to find a value as this handler doesn't exist.
def fail(*_):
raise ValueNotFoundException()
return fail
评论列表
文章目录