BREAKING: Add the ability to download and extract to a temp dir
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This also will execute any --exec scripts from the dest directory
This commit is contained in:
parent
6fe0869e8b
commit
0bb2277e26
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import platform
|
import platform
|
||||||
|
import tempfile
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
@ -552,6 +553,12 @@ def _parse_args(args: list[str] | None = None) -> argparse.Namespace:
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="Only print the URL and do not download",
|
help="Only print the URL and do not download",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--use-temp-dir",
|
||||||
|
"-t",
|
||||||
|
action="store_true",
|
||||||
|
help="Use a temporary directory as the destination",
|
||||||
|
)
|
||||||
|
|
||||||
parsed_args = parser.parse_args(args)
|
parsed_args = parser.parse_args(args)
|
||||||
|
|
||||||
@ -576,6 +583,9 @@ def _parse_args(args: list[str] | None = None) -> argparse.Namespace:
|
|||||||
if parsed_args.extract_all:
|
if parsed_args.extract_all:
|
||||||
parsed_args.extract_files = []
|
parsed_args.extract_files = []
|
||||||
|
|
||||||
|
if parsed_args.use_temp_dir:
|
||||||
|
parsed_args.destination = Path(tempfile.mkdtemp())
|
||||||
|
|
||||||
return parsed_args
|
return parsed_args
|
||||||
|
|
||||||
|
|
||||||
@ -683,7 +693,11 @@ def main():
|
|||||||
|
|
||||||
# Optionally execute post command
|
# Optionally execute post command
|
||||||
if args.exec:
|
if args.exec:
|
||||||
check_call(args.exec.format(asset["name"], **format_fields), shell=True)
|
check_call(
|
||||||
|
args.exec.format(asset["name"], **format_fields),
|
||||||
|
shell=True,
|
||||||
|
cwd=args.destination,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user