From 5878fe383459e94ad706c441c7c12c0d4558e58a Mon Sep 17 00:00:00 2001 From: Jef Mathiot <jeff.mathiot@gmail.com> Date: Fri, 2 May 2014 18:00:58 +0200 Subject: [PATCH] Add the ability to configure the project name --- fig/cli/command.py | 5 +++++ fig/cli/main.py | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fig/cli/command.py b/fig/cli/command.py index 0a224273c..cb256983a 100644 --- a/fig/cli/command.py +++ b/fig/cli/command.py @@ -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' diff --git a/fig/cli/main.py b/fig/cli/main.py index 1a26432a4..f58986458 100644 --- a/fig/cli/main.py +++ b/fig/cli/main.py @@ -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