Add the ability to configure the project name

This commit is contained in:
Jef Mathiot 2014-05-02 18:00:58 +02:00
parent 715e29d7ba
commit 5878fe3834
2 changed files with 9 additions and 3 deletions

View File

@ -24,6 +24,7 @@ class Command(DocoptCommand):
def __init__(self):
self.yaml_path = os.environ.get('FIG_FILE', None)
self.explicit_project_name = None
def dispatch(self, *args, **kwargs):
try:
@ -44,6 +45,8 @@ class Command(DocoptCommand):
def perform_command(self, options, *args, **kwargs):
if options['--file'] is not None:
self.yaml_path = os.path.join(self.base_dir, options['--file'])
if options['--project-name'] is not None:
self.explicit_project_name = options['--project-name']
return super(Command, self).perform_command(options, *args, **kwargs)
@cached_property
@ -70,6 +73,8 @@ class Command(DocoptCommand):
@cached_property
def project_name(self):
project = os.path.basename(os.getcwd())
if self.explicit_project_name is not None:
project = self.explicit_project_name
project = re.sub(r'[^a-zA-Z0-9]', '', project)
if not project:
project = 'default'

View File

@ -71,9 +71,10 @@ class TopLevelCommand(Command):
fig -h|--help
Options:
--verbose Show more output
--version Print version and exit
-f, --file FILE Specify an alternate fig file (default: fig.yml)
--verbose Show more output
--version Print version and exit
-f, --file FILE Specify an alternate fig file (default: fig.yml)
-p, --project-name NAME Specify an alternate project name (default: directory name)
Commands:
build Build or rebuild services