shellscripts 0.25.0__py3-none-any.whl → 0.25.2__py3-none-any.whl

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.
shell_scripts/__init__.py CHANGED
@@ -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
 
shell_scripts/config.py CHANGED
@@ -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",
shell_scripts/core.py CHANGED
@@ -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,9 +1,9 @@
1
- shell_scripts/__init__.py,sha256=sWpk4dCD9V5rWwB5mF0ld3eINn_1tk9T2otaWU4Q7z0,96
1
+ shell_scripts/__init__.py,sha256=4d-ScPDhq1Rvfc0yRdBd3KfqUeQdNONcCg404wdvb1A,96
2
2
  shell_scripts/__main__.py,sha256=-wEmwKTfeY5TphAH82E38XRPoB4KT5QDLDgRZz84PTs,83
3
- shell_scripts/config.py,sha256=YUs8QWsZ31lJPrMpFqvn7YLQdseQnlaiu7OXcXsKdEw,12640
4
- shell_scripts/core.py,sha256=Fcu8wGiBsLhouK4VSuVXsacT4f78HnXrm1LzwCeNkUs,11197
3
+ shell_scripts/config.py,sha256=bOFq3UxuTHPOqPc7lXLqri7f6NTaF19Mx1Q0i4rY3Dg,12624
4
+ shell_scripts/core.py,sha256=yDEWRoU20W2agzKQVa6P7moOnodAH0_5HAU0YDIlVuI,12774
5
5
  shell_scripts/utils.py,sha256=ckIJRJ_F7XTu_SqpFu_vI_70xNOmVM3S48YiTzxpO7o,14115
6
- shell_scripts/version_check.py,sha256=KVXVksy-T5V6rAYAnWACzv5MHi2dnrsYiNYg_yW0Eks,13184
6
+ shell_scripts/version_check.py,sha256=jW7VUGp0Cv3X8YaxVb91caz4NSABQSKWNRmOeTrEyuw,14386
7
7
  shell_scripts/commands/__init__.py,sha256=VoB5ucIdlUmcVdYV1JNgPvGBJU3aKPZMMMmY20Kjf5E,3682
8
8
  shell_scripts/commands/_dc_common.py,sha256=kfUn92r6n8F1w27jy5QDJE_6Kvpvzhq6dUGNs0_GO0U,4695
9
9
  shell_scripts/commands/agy.py,sha256=L2BFopbNEI40BDrEAs3P6sAJw78U50ZH1SbylkA79hc,2997
@@ -37,9 +37,9 @@ shell_scripts/commands/video2h265.py,sha256=Sr_UWGz_V77x4anmuy8kiWZv5I_AOFlV0WDn
37
37
  shell_scripts/commands/view_cmd.py,sha256=qHEivQHZpZCTE3VSFP1ay2SuqgancQlEKxJcKtyeqNA,1827
38
38
  shell_scripts/commands/vscode_cmd.py,sha256=Rkcjt5A1HMzqJoh2Yz9VRGoLP-L3qpRO5hkcSrzOmvA,1461
39
39
  shell_scripts/commands/vsinsider_cmd.py,sha256=KTTv1cVpJO-u1ktxOE0W_o4AAmz20pAvkDtyhpU9XBg,1548
40
- shellscripts-0.25.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
41
- shellscripts-0.25.0.dist-info/METADATA,sha256=-3I296fPkLpOPm5hgc1Qez5liP4AU7KfnK0WkkR0rZg,10771
42
- shellscripts-0.25.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
43
- shellscripts-0.25.0.dist-info/entry_points.txt,sha256=9ICAgH87fxHBzi3f6JXIVcsPWzAKsCh4_1xS8JThQ0M,85
44
- shellscripts-0.25.0.dist-info/top_level.txt,sha256=7bDVqjcR5CfCCArCP4X4e9gYJ-ua8z-GfQeHbAo8rCY,14
45
- shellscripts-0.25.0.dist-info/RECORD,,
40
+ shellscripts-0.25.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
41
+ shellscripts-0.25.2.dist-info/METADATA,sha256=sr999r0yDjmxXDLJaaKK5gkaSM7bHTj5QawYdEfvquI,11279
42
+ shellscripts-0.25.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
43
+ shellscripts-0.25.2.dist-info/entry_points.txt,sha256=9ICAgH87fxHBzi3f6JXIVcsPWzAKsCh4_1xS8JThQ0M,85
44
+ shellscripts-0.25.2.dist-info/top_level.txt,sha256=7bDVqjcR5CfCCArCP4X4e9gYJ-ua8z-GfQeHbAo8rCY,14
45
+ shellscripts-0.25.2.dist-info/RECORD,,