Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add force parameter to create #1870

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion docs/reference/commands/create.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ to delete and regenerate the app.
Options
=======

There are no additional command line options.
The following options can be provided at the command line.

``--auto-overwrite``
---------------------------------------

Automatically overwrite any existing scaffold for the nominated platform instead of asking for confirmation.
svdgoor marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 13 additions & 4 deletions src/briefcase/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ class CreateCommand(BaseCommand):
def app_template_url(self):
"""The URL for a cookiecutter repository to use when creating apps."""
return f"https://github.com/beeware/briefcase-{self.platform}-{self.output_format}-template.git"

def add_options(self, parser):
parser.add_argument(
"--auto-overwrite",
action="store_true",
help="Automatically confirm overwriting existing scaffold",
)

def support_package_filename(self, support_revision):
"""The query arguments to use in a support package query request."""
Expand Down Expand Up @@ -859,19 +866,20 @@ def cleanup_app_content(self, app: AppConfig):
self.logger.verbose(f"Removing {relative_path}")
path.unlink()

def create_app(self, app: AppConfig, test_mode: bool = False, **options):
def create_app(self, app: AppConfig, test_mode: bool = False, auto_confirm: bool = False, **options):
"""Create an application bundle.

:param app: The config object for the app
:param test_mode: Should the app be updated in test mode? (default: False)
:param auto_confirm: Should any existing scaffold be automatically overwritten? (default: False)
"""
if not app.supported:
raise UnsupportedPlatform(self.platform)

bundle_path = self.bundle_path(app)
if bundle_path.exists():
self.logger.info()
confirm = self.input.boolean_input(
confirm = auto_confirm or self.input.boolean_input(
f"Application {app.app_name!r} already exists; overwrite", default=False
)
if not confirm:
Expand Down Expand Up @@ -936,18 +944,19 @@ def verify_app_tools(self, app: AppConfig):
def __call__(
self,
app: AppConfig | None = None,
auto_overwrite: bool = False,
**options,
) -> dict | None:
# Confirm host compatibility, that all required tools are available,
# and that the app configuration is finalized.
self.finalize(app)

if app:
state = self.create_app(app, **options)
state = self.create_app(app, auto_overwrite, **options)
else:
state = None
for app_name, app in sorted(self.apps.items()):
state = self.create_app(app, **full_options(state, options))
state = self.create_app(app, auto_overwrite, **full_options(state, options))

return state

Expand Down
Loading