From ce8b29202605f5154ad121512ec04cf93201227a Mon Sep 17 00:00:00 2001 From: foefl Date: Thu, 17 Apr 2025 11:49:41 +0200 Subject: [PATCH] get cmd: delete archive by default, add option to keep files --- pyproject.toml | 4 ++-- src/pycage/get.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6d06ef2..504331d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pycage" -version = "0.2.4" +version = "0.2.5" description = "tool to handle standalone Python installations from the CLI" authors = [ {name = "Florian Förster", email = "f.foerster@d-opt.com"}, @@ -78,7 +78,7 @@ directory = "reports/coverage" [tool.bumpversion] -current_version = "0.2.4" +current_version = "0.2.5" parse = """(?x) (?P0|[1-9]\\d*)\\. (?P0|[1-9]\\d*)\\. diff --git a/src/pycage/get.py b/src/pycage/get.py index 2e5517b..0cca9bf 100644 --- a/src/pycage/get.py +++ b/src/pycage/get.py @@ -113,6 +113,14 @@ def extract_archive( default=None, help="specifiy a different target location, default: current working directory", ) +@click.option( + "-k", + "--keep", + is_flag=True, + show_default=True, + default=False, + help="keep the downloaded archive", +) @click.option( "-f", "--force-reextract", @@ -133,6 +141,7 @@ def get( release_tag: str | None, force_reextract: bool, dl_folder: Path | None, + keep: bool, ) -> None: url_metadata = cast(str, config.CFG["metadata"]["URL"]) os_file_info = config.CFG.os_info @@ -179,3 +188,12 @@ def get( ) except Exception as err: print_error(err) + + if not keep: + try: + src_file.unlink() + except Exception as err: + click.echo( + "The archive file could not be deleted because of following exception..." + ) + print_error(err)