shellscripts 0.25.0__tar.gz → 0.25.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. {shellscripts-0.25.0/src/shellscripts.egg-info → shellscripts-0.25.2}/PKG-INFO +15 -2
  2. {shellscripts-0.25.0 → shellscripts-0.25.2}/README.md +14 -1
  3. {shellscripts-0.25.0 → shellscripts-0.25.2}/pyproject.toml +1 -1
  4. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/__init__.py +1 -1
  5. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/config.py +2 -2
  6. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/core.py +46 -15
  7. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/version_check.py +41 -12
  8. {shellscripts-0.25.0 → shellscripts-0.25.2/src/shellscripts.egg-info}/PKG-INFO +15 -2
  9. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_014_pypi_version_source.py +184 -24
  10. {shellscripts-0.25.0 → shellscripts-0.25.2}/LICENSE +0 -0
  11. {shellscripts-0.25.0 → shellscripts-0.25.2}/setup.cfg +0 -0
  12. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/__main__.py +0 -0
  13. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/__init__.py +0 -0
  14. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/_dc_common.py +0 -0
  15. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/agy.py +0 -0
  16. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/bin_links.py +0 -0
  17. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/claude.py +0 -0
  18. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/clean.py +0 -0
  19. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/codex.py +0 -0
  20. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/copilot.py +0 -0
  21. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/dicom2jpg.py +0 -0
  22. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/dicomviewer.py +0 -0
  23. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/diff_cmd.py +0 -0
  24. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/doxygen_cmd.py +0 -0
  25. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/edit_cmd.py +0 -0
  26. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/gemini.py +0 -0
  27. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/kiro.py +0 -0
  28. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/opencode.py +0 -0
  29. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/pdf_crop.py +0 -0
  30. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/pdf_merge.py +0 -0
  31. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/pdf_split_by_format.py +0 -0
  32. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/pdf_split_by_toc.py +0 -0
  33. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/pdf_tiler_090.py +0 -0
  34. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/pdf_tiler_100.py +0 -0
  35. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/pdf_toc_clean.py +0 -0
  36. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/pi.py +0 -0
  37. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/req_cmd.py +0 -0
  38. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/tests_cmd.py +0 -0
  39. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/ubuntu_dark_theme.py +0 -0
  40. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/venv_cmd.py +0 -0
  41. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/video2h264.py +0 -0
  42. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/video2h265.py +0 -0
  43. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/view_cmd.py +0 -0
  44. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/vscode_cmd.py +0 -0
  45. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/commands/vsinsider_cmd.py +0 -0
  46. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shell_scripts/utils.py +0 -0
  47. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shellscripts.egg-info/SOURCES.txt +0 -0
  48. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shellscripts.egg-info/dependency_links.txt +0 -0
  49. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shellscripts.egg-info/entry_points.txt +0 -0
  50. {shellscripts-0.25.0 → shellscripts-0.25.2}/src/shellscripts.egg-info/top_level.txt +0 -0
  51. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_001_002_core.py +0 -0
  52. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_004_bin_links_clean.py +0 -0
  53. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_005_cli_launchers.py +0 -0
  54. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_006_dc_common.py +0 -0
  55. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_007_pdf_commands.py +0 -0
  56. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_008_env_commands.py +0 -0
  57. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_010_req_cmd.py +0 -0
  58. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_011_video_commands.py +0 -0
  59. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_012_workflow_runtime.py +0 -0
  60. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_013_release_pypi_gating.py +0 -0
  61. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_015_pre_release_check.py +0 -0
  62. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_016_release_precheck_gating.py +0 -0
  63. {shellscripts-0.25.0 → shellscripts-0.25.2}/tests/test_tst_017_agy_command.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shellscripts
3
- Version: 0.25.0
3
+ Version: 0.25.2
4
4
  Summary: Execute useful shell scripts via an uvx-compatible CLI interface.
5
5
  Author: Francesco Rolando
6
6
  License-Expression: GPL-3.0-only
@@ -31,7 +31,7 @@ Dynamic: license-file
31
31
  > * **No Support or Feature Requests:** Please **do not** open issues, bug reports, or feature requests. They will not be addressed or accepted at this stage of development.
32
32
  > * **No Warranty:** This software is provided **"AS IS"**, without warranty of any kind, express or implied. You may use it strictly for **testing and evaluation purposes** at your own sole risk.
33
33
 
34
- # s/shellScripts (0.25.0)
34
+ # s/shellScripts (0.25.2)
35
35
 
36
36
  <p align="center">
37
37
  <img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
@@ -106,6 +106,12 @@ Upgrade to the latest published PyPI release:
106
106
  s --upgrade
107
107
  ```
108
108
 
109
+ Force a complete re-download and reinstallation by appending the forced-reinstall options (`--force --reinstall --refresh`) to the configured upgrade command:
110
+
111
+ ```bash
112
+ s --upgrade --force
113
+ ```
114
+
109
115
 
110
116
  ### Run Without Installing (uvx)
111
117
 
@@ -145,6 +151,12 @@ s --upgrade --dev
145
151
  s --upgrade --develop
146
152
  ```
147
153
 
154
+ Add `--force` to force a complete re-download and reinstallation of the tagged release:
155
+
156
+ ```bash
157
+ s --upgrade --develop --force
158
+ ```
159
+
148
160
 
149
161
  ## Management Commands
150
162
 
@@ -161,6 +173,7 @@ Built-in management flags:
161
173
  - `--help` : show full help or command help (`shellscripts --help <command>`).
162
174
  - `--version` / `--ver` : print the installed version plus the latest versions available on PyPI and GitHub.
163
175
  - `--upgrade` : run the configured upgrade command automatically on Linux (installs the latest PyPI release by default), otherwise print the manual command.
176
+ - `--upgrade --force` : force download and complete reinstallation by appending `--force --reinstall --refresh` to the `--upgrade` or `--upgrade --dev`/`--upgrade --develop` command.
164
177
  - `--upgrade --dev` / `--upgrade --develop` : upgrade from the latest tagged GitHub release instead of PyPI, regardless of its source branch.
165
178
  - `--uninstall` : run configured uninstall command automatically on Linux, otherwise print the manual command.
166
179
  - `--write-config` : write the default runtime configuration file.
@@ -10,7 +10,7 @@
10
10
  > * **No Support or Feature Requests:** Please **do not** open issues, bug reports, or feature requests. They will not be addressed or accepted at this stage of development.
11
11
  > * **No Warranty:** This software is provided **"AS IS"**, without warranty of any kind, express or implied. You may use it strictly for **testing and evaluation purposes** at your own sole risk.
12
12
 
13
- # s/shellScripts (0.25.0)
13
+ # s/shellScripts (0.25.2)
14
14
 
15
15
  <p align="center">
16
16
  <img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
@@ -85,6 +85,12 @@ Upgrade to the latest published PyPI release:
85
85
  s --upgrade
86
86
  ```
87
87
 
88
+ Force a complete re-download and reinstallation by appending the forced-reinstall options (`--force --reinstall --refresh`) to the configured upgrade command:
89
+
90
+ ```bash
91
+ s --upgrade --force
92
+ ```
93
+
88
94
 
89
95
  ### Run Without Installing (uvx)
90
96
 
@@ -124,6 +130,12 @@ s --upgrade --dev
124
130
  s --upgrade --develop
125
131
  ```
126
132
 
133
+ Add `--force` to force a complete re-download and reinstallation of the tagged release:
134
+
135
+ ```bash
136
+ s --upgrade --develop --force
137
+ ```
138
+
127
139
 
128
140
  ## Management Commands
129
141
 
@@ -140,6 +152,7 @@ Built-in management flags:
140
152
  - `--help` : show full help or command help (`shellscripts --help <command>`).
141
153
  - `--version` / `--ver` : print the installed version plus the latest versions available on PyPI and GitHub.
142
154
  - `--upgrade` : run the configured upgrade command automatically on Linux (installs the latest PyPI release by default), otherwise print the manual command.
155
+ - `--upgrade --force` : force download and complete reinstallation by appending `--force --reinstall --refresh` to the `--upgrade` or `--upgrade --dev`/`--upgrade --develop` command.
143
156
  - `--upgrade --dev` / `--upgrade --develop` : upgrade from the latest tagged GitHub release instead of PyPI, regardless of its source branch.
144
157
  - `--uninstall` : run configured uninstall command automatically on Linux, otherwise print the manual command.
145
158
  - `--write-config` : write the default runtime configuration file.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "shellscripts"
7
- version = "0.25.0"
7
+ version = "0.25.2"
8
8
  description = "Execute useful shell scripts via an uvx-compatible CLI interface."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -1,4 +1,4 @@
1
- __version__ = "0.25.0"
1
+ __version__ = "0.25.2"
2
2
 
3
3
  from .core import main # noqa: F401
4
4
 
@@ -25,9 +25,9 @@ from shell_scripts.utils import print_warn
25
25
  # @satisfies DES-011, DES-012
26
26
  DEFAULT_RUNTIME_CONFIG: dict[str, Any] = {
27
27
  "management": {
28
- "upgrade": "uv tool install shellscripts --force",
28
+ "upgrade": "uv tool install shellscripts",
29
29
  "upgrade_develop": (
30
- "uv tool install shellscripts --force "
30
+ "uv tool install shellscripts "
31
31
  "--from git+https://github.com/Ogekuri/shellScripts.git@{tag}"
32
32
  ),
33
33
  "uninstall": "uv tool uninstall shellscripts",
@@ -3,9 +3,10 @@
3
3
 
4
4
  @details Provides global help rendering, management command execution
5
5
  (`--version`, `--ver`, `--upgrade`, `--uninstall`, `--write-config`,
6
- `--develop`/`--dev` upgrade selector), runtime
7
- configuration bootstrap, and subcommand delegation to lazily imported modules.
8
- @satisfies PRJ-001, PRJ-002, PRJ-003, REQ-001, REQ-002, REQ-003, REQ-004, REQ-005, REQ-045, REQ-046, REQ-048, REQ-049, REQ-050, REQ-051, REQ-052, REQ-053, REQ-054, REQ-056, REQ-064, REQ-065, REQ-066, REQ-068, REQ-069, REQ-075, REQ-076, REQ-077, REQ-078
6
+ `--develop`/`--dev` upgrade selector, `--force` forced-reinstall selector),
7
+ runtime configuration bootstrap, and subcommand delegation to lazily imported
8
+ modules.
9
+ @satisfies PRJ-001, PRJ-002, PRJ-003, REQ-001, REQ-002, REQ-003, REQ-004, REQ-005, REQ-045, REQ-046, REQ-048, REQ-049, REQ-050, REQ-051, REQ-052, REQ-053, REQ-054, REQ-056, REQ-064, REQ-065, REQ-066, REQ-068, REQ-069, REQ-075, REQ-076, REQ-077, REQ-078, REQ-087, REQ-088, REQ-089, REQ-090, REQ-091
9
10
  """
10
11
 
11
12
  import sys
@@ -17,7 +18,12 @@ from shell_scripts.config import (
17
18
  load_runtime_config,
18
19
  write_default_runtime_config,
19
20
  )
20
- from shell_scripts.version_check import check_for_updates, fetch_github_latest_release, print_remote_latest_versions
21
+ from shell_scripts.version_check import (
22
+ check_for_updates,
23
+ fetch_github_latest_release,
24
+ format_version_report_line,
25
+ print_remote_latest_versions,
26
+ )
21
27
  from shell_scripts.commands import get_command
22
28
  from shell_scripts.utils import (
23
29
  capture_terminal_state,
@@ -37,6 +43,14 @@ PROGRAM = "shellscripts"
37
43
  # @satisfies REQ-066
38
44
  HELP_COMMAND_COLUMN_WIDTH = 16
39
45
 
46
+ ## @var FORCED_REINSTALL_OPTIONS
47
+ # @brief Option suffix appended to upgrade commands when `--force` is active.
48
+ # @details Standard forced-reinstall options for `uv tool install`: replace
49
+ # the installed tool entry, reinstall the package, and refresh cached remote
50
+ # metadata so the upgrade performs a full re-download and reinstallation.
51
+ # @satisfies REQ-088, REQ-089
52
+ FORCED_REINSTALL_OPTIONS = "--force --reinstall --refresh"
53
+
40
54
  ## @var HELP_SECTION_COMMANDS
41
55
  # @brief Ordered command groups for global help rendering.
42
56
  # @details Defines deterministic section order and command-token order used by
@@ -142,6 +156,10 @@ def print_help(command_name=None):
142
156
  " --dev - With --upgrade: upgrade from the latest GitHub release tag"
143
157
  )
144
158
  print(" instead of PyPI (alias: --develop).")
159
+ print(
160
+ " --force - With --upgrade: force download and complete reinstallation"
161
+ )
162
+ print(" (appends --force --reinstall --refresh).")
145
163
  print(
146
164
  f" --uninstall - Uninstall {PROGRAM} on Linux; print manual command elsewhere."
147
165
  )
@@ -181,18 +199,21 @@ def _build_develop_upgrade_command(latest_tag: str) -> str:
181
199
  return template.replace("{tag}", latest_tag)
182
200
 
183
201
 
184
- def do_upgrade(develop: bool = False) -> int:
202
+ def do_upgrade(develop: bool = False, force: bool = False) -> int:
185
203
  """@brief Execute Linux-only upgrade command resolved from runtime config.
186
204
 
187
205
  @details Reads management command string from runtime config key
188
206
  `management.upgrade` (PyPI default) or, when `develop` is set, resolves
189
207
  the latest GitHub release tag and composes the tag-pinned upgrade command;
190
- executes it on Linux via shell invocation and prints the manual fallback
191
- command on non-Linux systems.
192
- @param develop {bool} Force upgrade from the latest GitHub release tag.
208
+ appends ` --force --reinstall --refresh` to the resolved command when
209
+ `force` is set; executes the composed command on Linux via shell
210
+ invocation and prints the manual fallback command on non-Linux systems.
211
+ Complexity O(n) over the composed command string length.
212
+ @param develop {bool} Select upgrade from the latest GitHub release tag.
213
+ @param force {bool} Append forced-reinstall options to the upgrade command.
193
214
  @return {int} `1` when develop tag resolution fails; subprocess return code
194
215
  on Linux; `0` on non-Linux fallback.
195
- @satisfies REQ-004, REQ-076, REQ-078, REQ-045, REQ-056
216
+ @satisfies REQ-004, REQ-076, REQ-078, REQ-087, REQ-088, REQ-089, REQ-045, REQ-056
196
217
  """
197
218
 
198
219
  if develop:
@@ -204,6 +225,8 @@ def do_upgrade(develop: bool = False) -> int:
204
225
  install_cmd = _build_develop_upgrade_command(latest_tag)
205
226
  else:
206
227
  install_cmd = get_management_command("upgrade")
228
+ if force:
229
+ install_cmd = f"{install_cmd} {FORCED_REINSTALL_OPTIONS}"
207
230
  if is_linux():
208
231
  require_shell_command_executables(install_cmd)
209
232
  print(f"Upgrading {PROGRAM}...")
@@ -260,13 +283,16 @@ def main():
260
283
 
261
284
  @details Performs runtime OS detection, update check, runtime configuration
262
285
  load, and argument dispatch through management flags (`--version` prints
263
- installed plus PyPI/GitHub latest versions; `--upgrade` upgrades from PyPI
264
- or, with `--develop`/`--dev`, from the latest GitHub release tag) and
265
- subcommands, then restores terminal raw/cbreak and disables legacy+xterm
286
+ the aligned three-line report with installed plus PyPI/GitHub latest
287
+ versions; `--upgrade` upgrades from PyPI
288
+ or, with `--develop`/`--dev`, from the latest GitHub release tag; `--force`
289
+ appends forced-reinstall options to the selected upgrade command; bare
290
+ `--develop`/`--dev`/`--force` selectors are rejected) and subcommands,
291
+ then restores terminal raw/cbreak and disables legacy+xterm
266
292
  mouse-tracking modes (`?9l`, `?1000l`, `?1001l`, `?1002l`, `?1003l`,
267
293
  `?1004l`, `?1005l`, `?1006l`, `?1007l`, `?1015l`, `?1016l`) before exit.
268
294
  @return {int} Process-compatible return code for caller (`sys.exit`).
269
- @satisfies PRJ-001, REQ-001, REQ-002, REQ-003, REQ-004, REQ-005, REQ-045, REQ-046, REQ-047, REQ-048, REQ-049, REQ-050, REQ-051, REQ-052, REQ-053, REQ-054, REQ-064, REQ-065, REQ-066, REQ-068, REQ-069, REQ-075, REQ-076, REQ-077, REQ-078
295
+ @satisfies PRJ-001, REQ-001, REQ-002, REQ-003, REQ-004, REQ-005, REQ-045, REQ-046, REQ-047, REQ-048, REQ-049, REQ-050, REQ-051, REQ-052, REQ-053, REQ-054, REQ-064, REQ-065, REQ-066, REQ-068, REQ-069, REQ-075, REQ-076, REQ-077, REQ-078, REQ-087, REQ-088, REQ-089, REQ-090, REQ-091
270
296
  """
271
297
  saved_tty = capture_terminal_state()
272
298
  try:
@@ -283,18 +309,23 @@ def main():
283
309
  first_arg = args[0]
284
310
 
285
311
  if first_arg in ("--version", "--ver"):
286
- print(__version__)
312
+ print(format_version_report_line("Current Installed", __version__))
287
313
  print_remote_latest_versions(__version__)
288
314
  return 0
289
315
 
290
316
  if first_arg == "--upgrade":
291
317
  develop = any(arg in ("--develop", "--dev") for arg in args[1:])
292
- return do_upgrade(develop=develop)
318
+ force = "--force" in args[1:]
319
+ return do_upgrade(develop=develop, force=force)
293
320
 
294
321
  if first_arg in ("--develop", "--dev"):
295
322
  print_error("--develop/--dev must be used together with --upgrade.")
296
323
  return 1
297
324
 
325
+ if first_arg == "--force":
326
+ print_error("--force must be used together with --upgrade.")
327
+ return 1
328
+
298
329
  if first_arg == "--uninstall":
299
330
  return do_uninstall()
300
331
 
@@ -258,32 +258,61 @@ def fetch_github_latest_release(current_version: str) -> str:
258
258
  return str(payload["tag_name"])
259
259
 
260
260
 
261
+ BRIGHT_GREEN = "\033[92m"
262
+ BRIGHT_RED = "\033[91m"
263
+ RESET = "\033[0m"
264
+
265
+ # @brief Fixed label column width for aligned `--version` report lines.
266
+ # @details Left-justifies every report label (`Current Installed`,
267
+ # `Latest @ PyPI`, `Latest @ GitHub`) before the `: ` value separator so all
268
+ # version tokens start at the same output column.
269
+ # @satisfies REQ-091
270
+ REPORT_LABEL_WIDTH = 18
271
+
272
+
273
+ def format_version_report_line(label: str, value: str) -> str:
274
+ """@brief Render one aligned `--version` report line.
275
+
276
+ @details Left-justifies the report label to `REPORT_LABEL_WIDTH`
277
+ characters, then appends `: ` and the raw value without color codes so
278
+ callers keep control of terminal coloring. Time complexity O(1).
279
+ @param label {str} Report label token (for example `Latest @ PyPI`).
280
+ @param value {str} Report value token (version string or
281
+ `unknown (<reason>)`).
282
+ @return {str} Aligned report line shaped as `<label>: <value>`.
283
+ @satisfies REQ-075, REQ-091
284
+ """
285
+ return f"{label:<{REPORT_LABEL_WIDTH}}: {value}"
286
+
287
+
261
288
  def print_remote_latest_versions(current_version: str) -> None:
262
289
  """@brief Print PyPI and GitHub latest-version report lines.
263
290
 
264
- @details Emits one `<source> latest: <version>` line per remote source in
265
- fixed order (PyPI, GitHub). A failed source lookup prints one bright-red
266
- `<source> latest: unknown (<reason>)` line where `<reason>` is the
267
- `_format_request_error` descriptor of the actual failure, and the remaining
268
- source is still processed. Complexity O(1) excluding network latency.
291
+ @details Emits one aligned `Latest @ <source>` line per remote source in
292
+ fixed order (PyPI, GitHub), left-justifying each label to
293
+ `REPORT_LABEL_WIDTH` characters. A failed source lookup prints one
294
+ bright-red aligned line whose value is `unknown (<reason>)` where
295
+ `<reason>` is the `_format_request_error` descriptor of the actual
296
+ failure, and the remaining source is still processed. Complexity O(1)
297
+ excluding network latency.
269
298
  @param current_version {str} Installed package version used in User-Agent.
270
299
  @return {None} Writes two report or error lines to stdout.
271
- @satisfies REQ-003, REQ-075, REQ-084, DES-020
300
+ @satisfies REQ-003, REQ-075, REQ-084, REQ-091, DES-020
272
301
  """
273
302
 
274
303
  for source_label, fetch_version in (
275
- ("PyPI", fetch_pypi_latest_version),
276
- ("GitHub", fetch_github_latest_release),
304
+ ("Latest @ PyPI", fetch_pypi_latest_version),
305
+ ("Latest @ GitHub", fetch_github_latest_release),
277
306
  ):
278
307
  try:
279
308
  latest_version = fetch_version(current_version).lstrip("v")
280
309
  except Exception as error:
281
- print(
282
- f"{BRIGHT_RED}{source_label} latest: unknown "
283
- f"({_format_request_error(error)}){RESET}"
310
+ failure_line = format_version_report_line(
311
+ source_label, f"unknown ({_format_request_error(error)})"
284
312
  )
313
+ print(f"{BRIGHT_RED}{failure_line}{RESET}")
285
314
  continue
286
- print(f"{source_label} latest: {latest_version}")
315
+ print(format_version_report_line(source_label, latest_version))
287
316
 
288
317
 
289
318
  def check_for_updates(current_version: str) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shellscripts
3
- Version: 0.25.0
3
+ Version: 0.25.2
4
4
  Summary: Execute useful shell scripts via an uvx-compatible CLI interface.
5
5
  Author: Francesco Rolando
6
6
  License-Expression: GPL-3.0-only
@@ -31,7 +31,7 @@ Dynamic: license-file
31
31
  > * **No Support or Feature Requests:** Please **do not** open issues, bug reports, or feature requests. They will not be addressed or accepted at this stage of development.
32
32
  > * **No Warranty:** This software is provided **"AS IS"**, without warranty of any kind, express or implied. You may use it strictly for **testing and evaluation purposes** at your own sole risk.
33
33
 
34
- # s/shellScripts (0.25.0)
34
+ # s/shellScripts (0.25.2)
35
35
 
36
36
  <p align="center">
37
37
  <img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
@@ -106,6 +106,12 @@ Upgrade to the latest published PyPI release:
106
106
  s --upgrade
107
107
  ```
108
108
 
109
+ Force a complete re-download and reinstallation by appending the forced-reinstall options (`--force --reinstall --refresh`) to the configured upgrade command:
110
+
111
+ ```bash
112
+ s --upgrade --force
113
+ ```
114
+
109
115
 
110
116
  ### Run Without Installing (uvx)
111
117
 
@@ -145,6 +151,12 @@ s --upgrade --dev
145
151
  s --upgrade --develop
146
152
  ```
147
153
 
154
+ Add `--force` to force a complete re-download and reinstallation of the tagged release:
155
+
156
+ ```bash
157
+ s --upgrade --develop --force
158
+ ```
159
+
148
160
 
149
161
  ## Management Commands
150
162
 
@@ -161,6 +173,7 @@ Built-in management flags:
161
173
  - `--help` : show full help or command help (`shellscripts --help <command>`).
162
174
  - `--version` / `--ver` : print the installed version plus the latest versions available on PyPI and GitHub.
163
175
  - `--upgrade` : run the configured upgrade command automatically on Linux (installs the latest PyPI release by default), otherwise print the manual command.
176
+ - `--upgrade --force` : force download and complete reinstallation by appending `--force --reinstall --refresh` to the `--upgrade` or `--upgrade --dev`/`--upgrade --develop` command.
164
177
  - `--upgrade --dev` / `--upgrade --develop` : upgrade from the latest tagged GitHub release instead of PyPI, regardless of its source branch.
165
178
  - `--uninstall` : run configured uninstall command automatically on Linux, otherwise print the manual command.
166
179
  - `--write-config` : write the default runtime configuration file.
@@ -1,14 +1,16 @@
1
1
  """
2
- @brief Validate PyPI-primary version sourcing, version reporting, and develop upgrade flows.
2
+ @brief Validate PyPI-primary version sourcing, version reporting, and upgrade flows.
3
3
  @details Verifies startup update checks against the PyPI JSON API, GitHub
4
- latest-release resolution, the three-line `--version` report, the PyPI
5
- default upgrade command, the `--upgrade --dev`/`--develop` GitHub-tagged
6
- upgrade command, develop-upgrade failure handling, and rejection of the
7
- develop selector without `--upgrade`. All HTTP and subprocess boundaries are
8
- monkeypatched; no real network, filesystem, clock, or randomness access.
4
+ latest-release resolution, the aligned three-line `--version` report, the PyPI
5
+ default upgrade command, the forced-reinstall `--force` suffix on PyPI and
6
+ GitHub-tagged upgrade commands, the `--upgrade --dev`/`--develop`
7
+ GitHub-tagged upgrade command, develop-upgrade failure handling, and
8
+ rejection of the develop and force selectors without `--upgrade`. All HTTP
9
+ and subprocess boundaries are monkeypatched; no real network, filesystem,
10
+ clock, or randomness access.
9
11
  Level classification: Level 0 tests exercise single module functions;
10
12
  Level 1 tests exercise `core.main` dispatch with patched boundaries.
11
- @satisfies TST-014, REQ-003, REQ-075, REQ-076, REQ-077, REQ-078, DES-018, DES-019, DES-020
13
+ @satisfies TST-014, REQ-003, REQ-075, REQ-076, REQ-077, REQ-078, REQ-087, REQ-088, REQ-089, REQ-090, DES-018, DES-019, DES-020
12
14
  @return {None} Pytest module scope.
13
15
  """
14
16
 
@@ -194,7 +196,7 @@ def test_print_remote_latest_versions_prints_both_latest_lines(
194
196
  version_check.print_remote_latest_versions("0.1.0")
195
197
  captured = capsys.readouterr()
196
198
 
197
- expected_output = ["PyPI latest: 1.2.3", "GitHub latest: 4.5.6"]
199
+ expected_output = ["Latest @ PyPI : 1.2.3", "Latest @ GitHub : 4.5.6"]
198
200
  assert captured.out.splitlines() == expected_output
199
201
 
200
202
 
@@ -205,8 +207,8 @@ def test_print_remote_latest_versions_reports_failed_source_and_continues(
205
207
  """
206
208
  @brief Validate per-source error reporting during version report.
207
209
  @details Forces the PyPI lookup to raise a non-HTTP exception and asserts
208
- the bright-red `PyPI latest: unknown (<reason>)` failure line while the
209
- GitHub line is still emitted.
210
+ the bright-red aligned `Latest @ PyPI : unknown (<reason>)` failure
211
+ line while the GitHub line is still emitted.
210
212
  @param monkeypatch {pytest.MonkeyPatch} Runtime patch helper.
211
213
  @param capsys {pytest.CaptureFixture[str]} Stdout/stderr capture helper.
212
214
  @return {None} Assertions only.
@@ -230,10 +232,10 @@ def test_print_remote_latest_versions_reports_failed_source_and_continues(
230
232
  version_check.print_remote_latest_versions("0.1.0")
231
233
  captured = capsys.readouterr()
232
234
 
233
- expected_output = "PyPI latest: unknown (URLError: <urlopen error pypi unreachable>)"
235
+ expected_output = "Latest @ PyPI : unknown (URLError: <urlopen error pypi unreachable>)"
234
236
  assert expected_output in captured.out
235
237
  assert "PyPI latest check failed" not in captured.out
236
- assert "GitHub latest: 0.1.0" in captured.out
238
+ assert "Latest @ GitHub : 0.1.0" in captured.out
237
239
 
238
240
 
239
241
  def test_print_remote_latest_versions_reports_github_http_404(
@@ -243,8 +245,8 @@ def test_print_remote_latest_versions_reports_github_http_404(
243
245
  """
244
246
  @brief Validate GitHub HTTP failure rendering during version report.
245
247
  @details Forces the GitHub lookup to raise an HTTP 404 error and asserts
246
- the bright-red `GitHub latest: unknown (HTTP 404)` failure line while
247
- the PyPI line is still emitted.
248
+ the bright-red aligned `Latest @ GitHub : unknown (HTTP 404)` failure
249
+ line while the PyPI line is still emitted.
248
250
  @param monkeypatch {pytest.MonkeyPatch} Runtime patch helper.
249
251
  @param capsys {pytest.CaptureFixture[str]} Stdout/stderr capture helper.
250
252
  @return {None} Assertions only.
@@ -272,10 +274,10 @@ def test_print_remote_latest_versions_reports_github_http_404(
272
274
  version_check.print_remote_latest_versions("0.1.0")
273
275
  captured = capsys.readouterr()
274
276
 
275
- expected_output = "GitHub latest: unknown (HTTP 404)"
277
+ expected_output = "Latest @ GitHub : unknown (HTTP 404)"
276
278
  assert expected_output in captured.out
277
279
  assert "GitHub latest check failed" not in captured.out
278
- assert "PyPI latest: 0.1.0" in captured.out
280
+ assert "Latest @ PyPI : 0.1.0" in captured.out
279
281
 
280
282
 
281
283
  def test_main_version_prints_installed_pypi_and_github_lines(
@@ -305,9 +307,9 @@ def test_main_version_prints_installed_pypi_and_github_lines(
305
307
  captured = capsys.readouterr()
306
308
 
307
309
  expected_output = [
308
- core.__version__,
309
- "PyPI latest: 2.0.0",
310
- "GitHub latest: 3.0.0",
310
+ f"Current Installed : {core.__version__}",
311
+ "Latest @ PyPI : 2.0.0",
312
+ "Latest @ GitHub : 3.0.0",
311
313
  ]
312
314
  assert result == 0
313
315
  assert captured.out.splitlines()[:3] == expected_output
@@ -349,7 +351,7 @@ def test_do_upgrade_default_resolves_pypi_command(monkeypatch):
349
351
 
350
352
  result = core.do_upgrade()
351
353
 
352
- expected_output = "uv tool install shellscripts --force"
354
+ expected_output = "uv tool install shellscripts"
353
355
  assert result == 0
354
356
  assert observed["shell"] is True
355
357
  assert observed["command"] == expected_output
@@ -363,7 +365,7 @@ def test_do_upgrade_develop_upgrades_from_latest_github_tag(monkeypatch):
363
365
  propagation.
364
366
  @param monkeypatch {pytest.MonkeyPatch} Runtime patch helper.
365
367
  @return {None} Assertions only.
366
- @satisfies TST-014, REQ-076, DES-019
368
+ @satisfies TST-014, REQ-076, REQ-087, DES-019
367
369
  """
368
370
  observed = {}
369
371
 
@@ -395,7 +397,7 @@ def test_do_upgrade_develop_upgrades_from_latest_github_tag(monkeypatch):
395
397
  result = core.do_upgrade(develop=True)
396
398
 
397
399
  expected_output = (
398
- "uv tool install shellscripts --force "
400
+ "uv tool install shellscripts "
399
401
  "--from git+https://github.com/Ogekuri/shellScripts.git@v1.2.3"
400
402
  )
401
403
  assert result == 5
@@ -403,6 +405,97 @@ def test_do_upgrade_develop_upgrades_from_latest_github_tag(monkeypatch):
403
405
  assert observed["command"] == expected_output
404
406
 
405
407
 
408
+ def test_do_upgrade_force_appends_reinstall_options(monkeypatch):
409
+ """
410
+ @brief Validate the forced PyPI upgrade command contract.
411
+ @details Forces the Linux path, keeps the real runtime-config resolution,
412
+ and intercepts subprocess invocation to assert that `force=True` appends
413
+ the forced-reinstall option suffix to the default PyPI command.
414
+ @param monkeypatch {pytest.MonkeyPatch} Runtime patch helper.
415
+ @return {None} Assertions only.
416
+ @satisfies TST-014, REQ-088
417
+ """
418
+ observed = {}
419
+
420
+ def _fake_run(command, shell=False):
421
+ """
422
+ @brief Mock subprocess.run for the upgrade path.
423
+ @param command {str} Shell command string.
424
+ @param shell {bool} Shell execution selector.
425
+ @return {types.SimpleNamespace} Object with returncode field.
426
+ """
427
+ observed["command"] = command
428
+ observed["shell"] = shell
429
+ return types.SimpleNamespace(returncode=0)
430
+
431
+ monkeypatch.setattr(core, "is_linux", lambda: True)
432
+ monkeypatch.setattr(
433
+ core, "require_shell_command_executables", lambda command: None
434
+ )
435
+ monkeypatch.setattr(
436
+ core,
437
+ "get_management_command",
438
+ lambda name: get_default_runtime_config()["management"][name],
439
+ )
440
+ monkeypatch.setattr(core.subprocess, "run", _fake_run)
441
+
442
+ result = core.do_upgrade(force=True)
443
+
444
+ expected_output = "uv tool install shellscripts --force --reinstall --refresh"
445
+ assert result == 0
446
+ assert observed["shell"] is True
447
+ assert observed["command"] == expected_output
448
+
449
+
450
+ def test_do_upgrade_develop_force_appends_reinstall_options(monkeypatch):
451
+ """
452
+ @brief Validate the forced develop upgrade command contract.
453
+ @details Patches the latest-tag resolution and intercepts subprocess
454
+ invocation to assert that `develop=True, force=True` composes the
455
+ tag-pinned GitHub install command with the forced-reinstall suffix.
456
+ @param monkeypatch {pytest.MonkeyPatch} Runtime patch helper.
457
+ @return {None} Assertions only.
458
+ @satisfies TST-014, REQ-089
459
+ """
460
+ observed = {}
461
+
462
+ def _fake_run(command, shell=False):
463
+ """
464
+ @brief Mock subprocess.run for the upgrade path.
465
+ @param command {str} Shell command string.
466
+ @param shell {bool} Shell execution selector.
467
+ @return {types.SimpleNamespace} Object with returncode field.
468
+ """
469
+ observed["command"] = command
470
+ observed["shell"] = shell
471
+ return types.SimpleNamespace(returncode=5)
472
+
473
+ monkeypatch.setattr(core, "is_linux", lambda: True)
474
+ monkeypatch.setattr(
475
+ core, "require_shell_command_executables", lambda command: None
476
+ )
477
+ monkeypatch.setattr(
478
+ core,
479
+ "get_management_command",
480
+ lambda name: get_default_runtime_config()["management"][name],
481
+ )
482
+ monkeypatch.setattr(
483
+ core, "fetch_github_latest_release", lambda _version: "v1.2.3"
484
+ )
485
+ monkeypatch.setattr(core.subprocess, "run", _fake_run)
486
+
487
+ result = core.do_upgrade(develop=True, force=True)
488
+
489
+ expected_output = (
490
+ "uv tool install shellscripts "
491
+ "--from git+https://github.com/Ogekuri/shellScripts.git@v1.2.3 "
492
+ "--force --reinstall --refresh"
493
+ )
494
+ assert result == 5
495
+ assert observed["shell"] is True
496
+ assert observed["command"] == expected_output
497
+
498
+
406
499
  def test_do_upgrade_develop_fails_when_tag_resolution_fails(
407
500
  monkeypatch,
408
501
  capsys,
@@ -481,10 +574,11 @@ def test_main_upgrade_accepts_develop_aliases(monkeypatch):
481
574
  """
482
575
  observed_calls = []
483
576
 
484
- def _record_upgrade(develop=False):
577
+ def _record_upgrade(develop=False, force=False):
485
578
  """
486
- @brief Record develop selector values.
579
+ @brief Record upgrade selector values.
487
580
  @param develop {bool} Develop selector flag.
581
+ @param force {bool} Forced-reinstall selector flag.
488
582
  @return {int} Deterministic success code.
489
583
  """
490
584
  observed_calls.append(develop)
@@ -503,3 +597,69 @@ def test_main_upgrade_accepts_develop_aliases(monkeypatch):
503
597
 
504
598
  expected_output = [True, True]
505
599
  assert observed_calls == expected_output
600
+
601
+
602
+ def test_main_upgrade_forwards_force_selector(monkeypatch):
603
+ """
604
+ @brief Validate forwarding of the force selector on the upgrade flag.
605
+ @details Replaces `do_upgrade` with a recorder and asserts the develop and
606
+ force selector pairs for plain, forced, forced-develop, and forced-alias
607
+ invocations.
608
+ @param monkeypatch {pytest.MonkeyPatch} Runtime patch helper.
609
+ @return {None} Assertions only.
610
+ @satisfies TST-014, REQ-088, REQ-089
611
+ """
612
+ observed_calls = []
613
+
614
+ def _record_upgrade(develop=False, force=False):
615
+ """
616
+ @brief Record upgrade selector values.
617
+ @param develop {bool} Develop selector flag.
618
+ @param force {bool} Forced-reinstall selector flag.
619
+ @return {int} Deterministic success code.
620
+ """
621
+ observed_calls.append((develop, force))
622
+ return 0
623
+
624
+ monkeypatch.setattr(core, "check_for_updates", lambda _version: None)
625
+ monkeypatch.setattr(core, "print_remote_latest_versions", lambda _version: None)
626
+ monkeypatch.setattr(core, "do_upgrade", _record_upgrade)
627
+
628
+ for argv_tail in (
629
+ ("--upgrade",),
630
+ ("--upgrade", "--force"),
631
+ ("--upgrade", "--develop", "--force"),
632
+ ("--upgrade", "--force", "--dev"),
633
+ ):
634
+ monkeypatch.setattr(core.sys, "argv", ["shellscripts", *argv_tail])
635
+ result = core.main()
636
+ assert result == 0
637
+
638
+ expected_output = [
639
+ (False, False),
640
+ (False, True),
641
+ (True, True),
642
+ (True, True),
643
+ ]
644
+ assert observed_calls == expected_output
645
+
646
+
647
+ def test_main_rejects_force_flag_without_upgrade(monkeypatch, capsys):
648
+ """
649
+ @brief Validate rejection of the bare force selector flag.
650
+ @details Injects `--force` as first argument and asserts return code `1`
651
+ plus an explanatory error line without upgrade execution.
652
+ @param monkeypatch {pytest.MonkeyPatch} Runtime patch helper.
653
+ @param capsys {pytest.CaptureFixture[str]} Stdout/stderr capture helper.
654
+ @return {None} Assertions only.
655
+ @satisfies TST-014, REQ-090
656
+ """
657
+ monkeypatch.setattr(core, "check_for_updates", lambda _version: None)
658
+ monkeypatch.setattr(core, "print_remote_latest_versions", lambda _version: None)
659
+
660
+ monkeypatch.setattr(core.sys, "argv", ["shellscripts", "--force"])
661
+ result = core.main()
662
+ captured = capsys.readouterr()
663
+
664
+ assert result == 1
665
+ assert "--force must be used together with --upgrade" in captured.err
File without changes
File without changes