Skip to content

Commit

Permalink
✨ Allow copy-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed May 29, 2018
1 parent a353b20 commit a9c7b97
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
3 changes: 2 additions & 1 deletion moban/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def handle_moban_file(moban_file, options):
raise exceptions.MobanfileGrammarException(
constants.ERROR_INVALID_MOBAN_FILE % moban_file
)
if constants.LABEL_TARGETS not in moban_file_configurations:
if (constants.LABEL_TARGETS not in moban_file_configurations and
constants.LABEL_COPY not in moban_file_configurations):
raise exceptions.MobanfileGrammarException(
constants.ERROR_NO_TARGETS % moban_file
)
Expand Down
33 changes: 20 additions & 13 deletions moban/mobanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,25 @@ def handle_moban_file_v1(moban_file_configurations, command_line_options):
moban_file_configurations[constants.LABEL_CONFIG],
)
merged_options = merge(command_line_options, constants.DEFAULT_OPTIONS)
list_of_templating_parameters = parse_targets(
merged_options, moban_file_configurations[constants.LABEL_TARGETS]
)
engine_class = EngineFactory.get_engine(
merged_options[constants.LABEL_TEMPLATE_TYPE]
)
engine = engine_class(
merged_options[constants.LABEL_TMPL_DIRS],
merged_options[constants.LABEL_CONFIG_DIR],
)
engine.render_to_files(list_of_templating_parameters)
engine.report()

targets = moban_file_configurations.get(constants.LABEL_TARGETS)
if targets:
list_of_templating_parameters = parse_targets(
merged_options, targets,
)
engine_class = EngineFactory.get_engine(
merged_options[constants.LABEL_TEMPLATE_TYPE]
)
engine = engine_class(
merged_options[constants.LABEL_TMPL_DIRS],
merged_options[constants.LABEL_CONFIG_DIR],
)
engine.render_to_files(list_of_templating_parameters)
engine.report()
number_of_templated_files = engine.number_of_templated_files()
else:
number_of_templated_files = 0

if constants.LABEL_COPY in moban_file_configurations:
number_of_copied_files = handle_copy(
merged_options[constants.LABEL_TMPL_DIRS],
Expand All @@ -50,7 +57,7 @@ def handle_moban_file_v1(moban_file_configurations, command_line_options):
else:
number_of_copied_files = 0
exit_code = reporter.convert_to_shell_exit_code(
engine.number_of_templated_files() + number_of_copied_files
number_of_templated_files + number_of_copied_files
)
reporter.report_up_to_date()
return exit_code

0 comments on commit a9c7b97

Please sign in to comment.