Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manageprojects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Manage Python / Django projects
"""

__version__ = '0.9.7'
__version__ = '0.9.8'
__author__ = 'Jens Diemer <[email protected]>'
7 changes: 7 additions & 0 deletions manageprojects/cli/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,15 @@ def clone_project(
@click.command()
@click.argument('project_path', **ARGUMENT_EXISTING_DIR)
@click.argument('destination', **ARGUMENT_NOT_EXISTING_DIR)
@click.option(
'--overwrite/--no-overwrite',
**OPTION_ARGS_DEFAULT_FALSE,
help='Overwrite existing files.',
)
def reverse(
project_path: Path,
destination: Path,
overwrite: bool,
):
"""
Create a cookiecutter template from a managed project.
Expand All @@ -383,6 +389,7 @@ def reverse(
return reverse_managed_project(
project_path=project_path,
destination=destination,
overwrite=overwrite,
)


Expand Down
4 changes: 3 additions & 1 deletion manageprojects/cookiecutter_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ def create_cookiecutter_template(
source_path: Path,
destination: Path,
cookiecutter_context: dict,
overwrite: bool = False,
):
source_path = source_path.resolve()
assert_is_dir(source_path)
assert not destination.exists(), f'Destination {destination} already exists!'
if not overwrite:
assert not destination.exists(), f'Destination {destination} already exists!'

reverse_info = generate_reverse_info(cookiecutter_context=cookiecutter_context)

Expand Down
4 changes: 3 additions & 1 deletion manageprojects/cookiecutter_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,13 @@ def reverse_managed_project(
*,
project_path: Path,
destination: Path,
overwrite: bool = False,
):
"""
Create a cookiecutter template from a managed project.
"""
rprint(f'Create cookiecutter template from {project_path} in {destination}')
if destination.exists():
if not overwrite and destination.exists():
print(f'ERROR: Destination {destination} already exists!')
sys.exit(1)

Expand All @@ -273,4 +274,5 @@ def reverse_managed_project(
source_path=project_path,
destination=destination,
cookiecutter_context=cookiecutter_context,
overwrite=overwrite,
)