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

cli: Add --destructive-mode to clean #2577

Merged
merged 2 commits into from
Jun 4, 2019
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
12 changes: 10 additions & 2 deletions snapcraft/cli/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,15 @@ def pack(directory, output, **kwargs):
required=False,
help="Forces snapcraft to use LXD for this clean command.",
)
@click.option(
"--destructive-mode",
is_flag=True,
required=False,
help="Forces snapcraft to try and use the current host to clean.",
)
@click.option("--unprime", is_flag=True, required=False, cls=HiddenOption)
@click.option("--step", required=False, cls=HiddenOption)
def clean(parts, use_lxd, unprime, step):
def clean(parts, use_lxd, destructive_mode, unprime, step):
"""Remove a part's assets.

\b
Expand All @@ -313,7 +319,9 @@ def clean(parts, use_lxd, unprime, step):
if step:
raise click.BadOptionUsage("no such option: --step")

build_environment = get_build_environment(use_lxd=use_lxd)
build_environment = get_build_environment(
use_lxd=use_lxd, destructive_mode=destructive_mode
)
project = get_project(is_managed_host=build_environment.is_managed_host)

if unprime and not build_environment.is_managed_host:
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/commands/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ def test_unprime_fails(self):

self.assertThat(result.exit_code, Equals(2))

def test_destructive_mode(self):
self.make_snapcraft_yaml()

result = self.run_command(["clean", "--destructive-mode"])

self.assertThat(result.exit_code, Equals(0))


class CleanCommandPartsTestCase(CleanCommandBaseTestCase):
def test_local_plugin_not_removed(self):
Expand Down