Skip to content

Commit

Permalink
Add --status/--no-status options to 'shinylive assets download'
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Sep 5, 2024
1 parent 28cf1dd commit d75abe7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [UNRELEASED]

* Download status is now displayed while downloading Shinylive assets.

## [0.6.0] - 2024-09-03

Expand Down
4 changes: 4 additions & 0 deletions shinylive/_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def download_shinylive(
destdir: str | Path | None = None,
version: str = SHINYLIVE_ASSETS_VERSION,
url: Optional[str] = None,
status: bool = True,
) -> None:
if destdir is None:
# Note that this is the cache directory, which is the parent of the assets
Expand All @@ -36,6 +37,9 @@ def download_shinylive(
last_update_time = start_time

def reporthook(count: int, block_size: int, total_size: int):
if not status:
return

nonlocal last_update_time
current_time = time.time()

Expand Down
9 changes: 8 additions & 1 deletion shinylive/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,21 @@ def assets_info(
default=None,
help="URL to download from. If used, this will override --version.",
)
@click.option(
"--status/--no-status",
is_flag=True,
default=True,
help="Enable/disable status output during download.",
)
def download(
version: str,
dir: Optional[str | Path],
url: Optional[str],
status: bool,
) -> None:
if version is None: # pyright: ignore[reportUnnecessaryComparison]
version = SHINYLIVE_ASSETS_VERSION
_assets.download_shinylive(destdir=upgrade_dir(dir), version=version, url=url)
_assets.download_shinylive(destdir=upgrade_dir(dir), version=version, url=url, status=status)


cleanup_help = f"Remove all versions of local assets except the currently-used version, {SHINYLIVE_ASSETS_VERSION}."
Expand Down

0 comments on commit d75abe7

Please sign in to comment.