fix: point a declined download at the c entry

Saying no to a large download sent a beginner to --help. When the
question about what to install was asked, the line now names the c
entry, and i with its size when installed cores were found.
This commit is contained in:
Abdessamad Derraz committed 2026-10-23 14:10:27 +02:00
1 parent ebfa0cbb31
commit 83973e1415
4 files changed
+50 -3

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@
$ErrorActionPreference = "Stop"
$defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
$defaultInstallSha256 = "b5070145ae7920b90e8d904552a223261fae35a394552c7ce3a2b87cbcf613e8"
$defaultInstallSha256 = "a0b6a103d350e49f2751928c5a5560e239c52df81637a656e0691b9934e438bb"
$maximumInstallerBytes = 2MB
$installerExit = 0
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
+12 -1
View File
@@ -7561,6 +7561,8 @@ def _install(args: argparse.Namespace, real_stdout: TextIO) -> None:
# What --core resolves against, for advice that names one.
core_choices = set(available_choices(files, omitted_files)["cores"])
selection = _requested_narrowing(args, plat_name, files, omitted_files, manifest)
# What declining the size question points back at, when it was asked.
smaller = ""
if (
selection is None
and interactive
@@ -7576,6 +7578,13 @@ def _install(args: argparse.Namespace, real_stdout: TextIO) -> None:
plat_name, files, omitted_files, installed,
display_name(plat_name, manifest),
)
if selection is None:
smaller = (" Nothing downloaded. To install less, run the same command "
"again and type c at the first question to choose systems")
if installed is not None:
smaller += (f", or i for only what the installed cores read "
f"({format_size(_bytes(installed[0]))})")
smaller += "."
if selection == INSTALLED_ONLY:
files, omitted_files = installed
print("\n Same choice without questions: "
@@ -7752,7 +7761,9 @@ def _install(args: argparse.Namespace, real_stdout: TextIO) -> None:
f"\nDownload {format_size(dl_size)} to {bios_path}? [Y/n] "
)
):
print(" Nothing downloaded. --system, --core and --region "
# A beginner who just passed the c entry was sent to a
# 91-line --help.
print(smaller or " Nothing downloaded. --system, --core and --region "
"install less (see --help).")
total_up_to_date += len(up_to_date)
total_declined += len(to_download)
+1 -1
View File
@@ -18,7 +18,7 @@ esac
TEMP_INSTALLER=""
TEMP_DIRECTORY=""
DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
DEFAULT_INSTALL_SHA256="b5070145ae7920b90e8d904552a223261fae35a394552c7ce3a2b87cbcf613e8"
DEFAULT_INSTALL_SHA256="a0b6a103d350e49f2751928c5a5560e239c52df81637a656e0691b9934e438bb"
MAX_INSTALLER_BYTES=2097152
cleanup() {
+36
View File
@@ -354,6 +354,42 @@ class CommandLineChoices(unittest.TestCase):
install.parse_selection(bad, 5)
class DecliningTheSizePointsAtTheChoice(unittest.TestCase):
"""Saying no to `Download 8.4 GB?` printed "--system, --core and
--region install less (see --help)": a 91-line help for someone who had
just passed the c entry that does it."""
def _run(self, answers: list[str], *options: str) -> str:
replies = iter(answers)
out = io.StringIO()
with FakeRepository() as repo, \
mock.patch.object(sys, "argv", ["install.py", "--platform", "retroarch",
"--dest", str(repo.dest), *options]), \
mock.patch.object(install, "MANIFEST_URL",
repo.env()["RETROBIOS_BASE_URL"] + "/install/{platform}.json"), \
mock.patch.object(install, "RAW_FILE_URL",
repo.env()["RETROBIOS_BASE_URL"] + "/{path}"), \
mock.patch.object(install, "CONFIRM_FROM_BYTES", 1), \
mock.patch("sys.stdin", mock.Mock(isatty=lambda: True)), \
mock.patch("builtins.input", lambda _prompt="": next(replies)), \
contextlib.redirect_stdout(out):
try:
install.main()
except SystemExit:
pass
self.assertEqual(repo.installed(), [])
return out.getvalue()
def test_install_everything_then_no_names_the_c_entry(self):
out = self._run(["", "n"])
self.assertIn("type c at the first question", out)
self.assertNotIn("see --help", out)
def test_options_given_keep_the_option_advice(self):
out = self._run(["n"], "--system", "sony-playstation")
self.assertIn("--system, --core and --region install less", out)
class ACoreWithNoFileOfItsOwn(unittest.TestCase):
"""pcsx_rearmed, swanstation and pcsx1 showed `0 files, 0 B` in the
cores step and in --list-cores, which reads as "this core gets nothing":