← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] ~lgp171188/lpcraft:add-clean-command-clean-flag into lpcraft:main

 

> Before I continue with the review, could you please run the linters?

I have already run the linters locally before I created this merge proposal and did not see any linter errors. Did you see any issues?

> P.S.: During retro you mentioned that the development documentation could be improved. If you find the above instructions useful, maybe you could also add it the the MP you will create to update the documentation.

I am working on the changes and will create a separate merge proposal for it.

Diff comments:

> diff --git a/lpcraft/commands/clean.py b/lpcraft/commands/clean.py
> new file mode 100644
> index 0000000..d92dd32
> --- /dev/null
> +++ b/lpcraft/commands/clean.py
> @@ -0,0 +1,32 @@
> +# Copyright 2022 Canonical Ltd.  This software is licensed under the
> +# GNU General Public License version 3 (see the file LICENSE).
> +
> +from argparse import Namespace
> +from pathlib import Path
> +
> +from craft_cli import emit
> +
> +from lpcraft.config import Config
> +from lpcraft.providers import get_provider
> +
> +
> +def clean(args: Namespace) -> int:
> +    """
> +    Clean the managed environments for a project.
> +    """
> +    # Verify that the there is an lpcraft configuration file
> +    # before trying to clean a project.
> +    config_path = getattr(args, "config", Path(".launchpad.yaml"))
> +    _ = Config.load(config_path)

I didn't think straight when writing this - I was trying to avoid the unused variable issue but somehow wrote this instead of just calling the method without assigning the return value. 🤦‍♂️ Fixing in the next revision.

> +
> +    cwd = Path.cwd()
> +    emit.progress(f"Cleaning project {cwd.name!r}.")
> +
> +    provider = get_provider()
> +    provider.ensure_provider_is_available()
> +
> +    provider.clean_project_environments(
> +        project_name=cwd.name, project_path=cwd
> +    )
> +    emit.message(f"Cleaned project {cwd.name!r}.")
> +    return 0


-- 
https://code.launchpad.net/~lgp171188/lpcraft/+git/lpcraft/+merge/416656
Your team Launchpad code reviewers is requested to review the proposed merge of ~lgp171188/lpcraft:add-clean-command-clean-flag into lpcraft:main.



References