usecli 0.2.4__tar.gz → 0.2.6__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 (87) hide show
  1. {usecli-0.2.4 → usecli-0.2.6}/PKG-INFO +1 -1
  2. {usecli-0.2.4 → usecli-0.2.6}/pyproject.toml +1 -1
  3. {usecli-0.2.4 → usecli-0.2.6}/pyproject.toml.orig +1 -1
  4. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/__init__.py +12 -2
  5. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/base/about_command.py +25 -2
  6. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/base_command.py +10 -1
  7. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/exceptions/usage.py +32 -3
  8. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/ui/title.py +6 -6
  9. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/templates/usecli.config.toml.j2 +3 -1
  10. {usecli-0.2.4 → usecli-0.2.6}/LICENSE +0 -0
  11. {usecli-0.2.4 → usecli-0.2.6}/README.md +0 -0
  12. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/bundler/__init__.py +0 -0
  13. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/bundler/__main__.py +0 -0
  14. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/__init__.py +0 -0
  15. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/README.md +0 -0
  16. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/__init__.py +0 -0
  17. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/custom/README.md +0 -0
  18. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/custom/__init__.py +0 -0
  19. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/__init__.py +0 -0
  20. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/base/__init__.py +0 -0
  21. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/base/help_command.py +0 -0
  22. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/base/inspire_command.py +0 -0
  23. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/base/internal/__init__.py +0 -0
  24. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/base/internal/interactive_command.py +0 -0
  25. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/base/upgrade_command.py +0 -0
  26. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/core/__init__.py +0 -0
  27. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/core/utils.py +0 -0
  28. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/make/__init__.py +0 -0
  29. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/make/make_bundle_command.py +0 -0
  30. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/make/make_command.py +0 -0
  31. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/defaults/make/make_theme_command.py +0 -0
  32. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/commands/init_command.py +0 -0
  33. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/config/__init__.py +0 -0
  34. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/config/colors.py +0 -0
  35. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/__init__.py +0 -0
  36. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/_typer_compat.py +0 -0
  37. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/error/__init__.py +0 -0
  38. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/error/handler.py +0 -0
  39. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/error/utils.py +0 -0
  40. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/exceptions/__init__.py +0 -0
  41. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/exceptions/base.py +0 -0
  42. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/exceptions/config.py +0 -0
  43. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/exceptions/validation.py +0 -0
  44. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/runtime.py +0 -0
  45. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/ui/__init__.py +0 -0
  46. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/ui/list.py +0 -0
  47. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/ui/title.txt +0 -0
  48. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/validators/__init__.py +0 -0
  49. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/validators/network.py +0 -0
  50. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/validators/numeric.py +0 -0
  51. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/validators/path.py +0 -0
  52. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/core/validators/string.py +0 -0
  53. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/services/__init__.py +0 -0
  54. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/services/command_service.py +0 -0
  55. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/templates/command.py.j2 +0 -0
  56. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/templates/theme.toml.j2 +0 -0
  57. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/ayu_dark.toml +0 -0
  58. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/catppuccin_frappe.toml +0 -0
  59. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/catppuccin_latte.toml +0 -0
  60. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/catppuccin_macchiato.toml +0 -0
  61. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/catppuccin_mocha.toml +0 -0
  62. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/default.toml +0 -0
  63. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/dracula.toml +0 -0
  64. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/gruvbox_dark.toml +0 -0
  65. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/nord.toml +0 -0
  66. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/themes/tokyo_night.toml +0 -0
  67. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/utils/__init__.py +0 -0
  68. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/utils/interactive/__init__.py +0 -0
  69. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/utils/interactive/prompt_input.py +0 -0
  70. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/cli/utils/interactive/terminal_menu.py +0 -0
  71. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/entry.py +0 -0
  72. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/menu.py +0 -0
  73. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/params.py +0 -0
  74. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/progress.py +0 -0
  75. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/__init__.py +0 -0
  76. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/config/__init__.py +0 -0
  77. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/config/globals.py +0 -0
  78. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/config/manager.py +0 -0
  79. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/upgrades/__init__.py +0 -0
  80. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/upgrades/checker.py +0 -0
  81. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/upgrades/discovery.py +0 -0
  82. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/upgrades/installer.py +0 -0
  83. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/upgrades/pyproject.py +0 -0
  84. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/upgrades/service.py +0 -0
  85. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/shared/upgrades/settings.py +0 -0
  86. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/ui.py +0 -0
  87. {usecli-0.2.4 → usecli-0.2.6}/src/usecli/usecli.config.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: usecli
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: A powerful Python CLI framework for building beautiful, developer-friendly command-line tools.
5
5
  Author: Edward Boswell
6
6
  Author-email: Edward Boswell <thememium@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "usecli"
3
- version = "0.2.4"
3
+ version = "0.2.6"
4
4
  description = "A powerful Python CLI framework for building beautiful, developer-friendly command-line tools."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "usecli"
3
- version = "0.2.4"
3
+ version = "0.2.6"
4
4
  description = "A powerful Python CLI framework for building beautiful, developer-friendly command-line tools."
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Edward Boswell", email = "thememium@gmail.com" }]
@@ -297,7 +297,12 @@ def _ensure_cli_initialized() -> None:
297
297
  except _TyperBadParameter as e:
298
298
  from usecli.cli.core.exceptions import UsecliBadParameter
299
299
 
300
- styled_error = UsecliBadParameter(e.message, ctx=e.ctx, param=e.param)
300
+ styled_error = UsecliBadParameter(
301
+ e.message,
302
+ ctx=e.ctx,
303
+ param=e.param,
304
+ formatted_message=e.format_message(),
305
+ )
301
306
  styled_error.show()
302
307
  sys.exit(styled_error.exit_code)
303
308
  except _TyperUsageError as e:
@@ -627,7 +632,12 @@ def main() -> None:
627
632
  except _TyperBadParameter as e:
628
633
  from usecli.cli.core.exceptions import UsecliBadParameter
629
634
 
630
- styled_error = UsecliBadParameter(e.message, ctx=e.ctx, param=e.param)
635
+ styled_error = UsecliBadParameter(
636
+ e.message,
637
+ ctx=e.ctx,
638
+ param=e.param,
639
+ formatted_message=e.format_message(),
640
+ )
631
641
  styled_error.show()
632
642
  sys.exit(styled_error.exit_code)
633
643
  except _TyperUsageError as e:
@@ -1,9 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
+ import re
4
5
  import sys
5
6
  import tomllib
6
7
  from importlib.metadata import PackageNotFoundError
8
+ from importlib.metadata import version as get_version
7
9
  from pathlib import Path
8
10
 
9
11
  from usecli.cli.config.colors import COLOR
@@ -66,6 +68,22 @@ def _parse_dependency_requirement(req: str) -> tuple[str, str | None]:
66
68
  return name, remainder
67
69
 
68
70
 
71
+ def _is_extra_requirement(req: str) -> bool:
72
+ """True when the requirement's marker gates it behind an optional extra."""
73
+ _, sep, marker = req.partition(";")
74
+ if not sep:
75
+ return False
76
+ return re.search(r"\bextra\b", marker) is not None
77
+
78
+
79
+ def _is_dependency_installed(name: str) -> bool:
80
+ try:
81
+ get_version(name)
82
+ except (PackageNotFoundError, OSError):
83
+ return False
84
+ return True
85
+
86
+
69
87
  def _get_console_script_distribution(command_name: str | None):
70
88
  if not command_name:
71
89
  return None
@@ -81,8 +99,13 @@ def _get_package_dependencies_from_distribution(dist) -> list[tuple[str, str | N
81
99
  if not isinstance(req, str):
82
100
  continue
83
101
  name, spec = _parse_dependency_requirement(req)
84
- if name and not req.startswith("("):
85
- result.append((name, spec))
102
+ if not name or req.startswith("("):
103
+ continue
104
+ # ``dist.requires`` includes extra-gated requirements. Those are
105
+ # optional, so only list them when they are actually installed.
106
+ if _is_extra_requirement(req) and not _is_dependency_installed(name):
107
+ continue
108
+ result.append((name, spec))
86
109
  return result
87
110
 
88
111
 
@@ -412,9 +412,18 @@ class BaseCommand(ABC):
412
412
  return parts[0]
413
413
 
414
414
  def is_hidden(self) -> bool:
415
- """Whether ``[usecli.commands] hidden`` lists this command name."""
415
+ """Whether ``[usecli.commands] hidden`` lists this command name.
416
+
417
+ Hiding is a project-CLI concern. The ``usecli`` framework binary always
418
+ exposes its built-ins, even when run inside a project whose config hides
419
+ them, so scaffolding commands stay reachable.
420
+ """
421
+ from usecli.cli.core.ui.title import running_framework_distribution
416
422
  from usecli.shared.config.manager import get_config
417
423
 
424
+ if running_framework_distribution() is not None:
425
+ return False
426
+
418
427
  hidden = get_config().get("commands.hidden", [])
419
428
  if isinstance(hidden, str):
420
429
  hidden = [hidden]
@@ -3,9 +3,11 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import sys
6
+ from collections.abc import Sequence
6
7
  from typing import IO
7
8
 
8
9
  from click.core import Context as ClickContext
10
+ from click.core import Parameter as ClickParameter
9
11
  from click.exceptions import BadParameter, Exit, UsageError
10
12
  from rich.console import Console
11
13
 
@@ -67,7 +69,8 @@ class UsecliUsageError(UsageError):
67
69
  if self.ctx:
68
70
  console.print()
69
71
  help_text = _get_help_text_with_command_name(self.ctx)
70
- console.print(help_text)
72
+ if help_text:
73
+ console.print(help_text)
71
74
 
72
75
 
73
76
  class UsecliBadParameter(BadParameter):
@@ -77,6 +80,30 @@ class UsecliBadParameter(BadParameter):
77
80
  Provides highlighted error boxes and command help on validation failures.
78
81
  """
79
82
 
83
+ def __init__(
84
+ self,
85
+ message: str,
86
+ ctx: ClickContext | None = None,
87
+ param: ClickParameter | None = None,
88
+ param_hint: str | Sequence[str] | None = None,
89
+ formatted_message: str | None = None,
90
+ ) -> None:
91
+ """Initialize the styled parameter error.
92
+
93
+ Args:
94
+ message: Raw error reason (Click's ``BadParameter.message``).
95
+ ctx: Click context used to render command help.
96
+ param: Parameter the error refers to.
97
+ param_hint: Explicit hint replacing the parameter-derived hint.
98
+ formatted_message: Fully formatted message to render instead of
99
+ rebuilding one from ``message``. Wrappers use this to keep
100
+ the original exception's wording (for example Click's
101
+ ``MissingParameter``, whose reason lives only in
102
+ ``format_message``).
103
+ """
104
+ super().__init__(message, ctx=ctx, param=param, param_hint=param_hint)
105
+ self.formatted_message = formatted_message
106
+
80
107
  def show(self, file: IO[str] | None = None) -> None:
81
108
  """Display styled parameter error with command help.
82
109
 
@@ -88,12 +115,14 @@ class UsecliBadParameter(BadParameter):
88
115
 
89
116
  console.print()
90
117
 
118
+ message = self.formatted_message or self.format_message()
91
119
  error_prefix = (
92
120
  f"[bold black on {COLOR.ERROR}] ERROR [/bold black on {COLOR.ERROR}]"
93
121
  )
94
- error_msg = f"[bold {COLOR.ERROR}]{self.format_message()}[/bold {COLOR.ERROR}]"
122
+ error_msg = f"[bold {COLOR.ERROR}]{message}[/bold {COLOR.ERROR}]"
95
123
  console.print(f"{error_prefix} {error_msg}")
96
124
 
97
125
  if self.ctx:
98
126
  help_text = _get_help_text_with_command_name(self.ctx)
99
- console.print(help_text)
127
+ if help_text:
128
+ console.print(help_text)
@@ -32,7 +32,7 @@ def _invoked_script_name() -> str | None:
32
32
  return name
33
33
 
34
34
 
35
- def _running_framework_distribution() -> Any | None:
35
+ def running_framework_distribution() -> Any | None:
36
36
  """Return the usecli distribution when running as one of its console scripts.
37
37
 
38
38
  The invoked console script decides the process identity: ``usecli`` (or
@@ -69,7 +69,7 @@ def get_framework_description() -> str | None:
69
69
  Returns ``None`` for downstream CLIs, whose config description owns the
70
70
  banner.
71
71
  """
72
- dist = _running_framework_distribution()
72
+ dist = running_framework_distribution()
73
73
  if dist is None:
74
74
  return None
75
75
  summary = dist.metadata.get("Summary")
@@ -125,7 +125,7 @@ def get_script_command_name(default: str | None = None) -> str | None:
125
125
  The usecli binary reports itself, not the project's CLI name: a user who
126
126
  typed ``usecli`` must see ``usecli`` in usage output.
127
127
  """
128
- if _running_framework_distribution() is not None:
128
+ if running_framework_distribution() is not None:
129
129
  return "usecli"
130
130
 
131
131
  config = get_config()
@@ -149,7 +149,7 @@ def get_project_name() -> str:
149
149
  The usecli binary reports the framework name; downstream CLIs report the
150
150
  title configured for their project.
151
151
  """
152
- if _running_framework_distribution() is not None:
152
+ if running_framework_distribution() is not None:
153
153
  return "useCli"
154
154
 
155
155
  # First, try to get the title from the config
@@ -206,7 +206,7 @@ def get_project_version() -> str | None:
206
206
  CLI resolves the distribution that owns the invoked console script first,
207
207
  then falls back to ``[project].version`` in the project's pyproject.toml.
208
208
  """
209
- framework_dist = _running_framework_distribution()
209
+ framework_dist = running_framework_distribution()
210
210
  if framework_dist is not None:
211
211
  return _distribution_version(framework_dist)
212
212
 
@@ -234,7 +234,7 @@ def _banner_config():
234
234
  the downstream project being scaffolded. Downstream CLIs keep using the
235
235
  discovered project config.
236
236
  """
237
- if _running_framework_distribution() is None:
237
+ if running_framework_distribution() is None:
238
238
  return get_config()
239
239
 
240
240
  from usecli.shared.config.globals import PACKAGE_ROOT
@@ -32,7 +32,9 @@ show_version = {{ show_version | default(true) | lower }}
32
32
  show_description = {{ show_description | default(true) | lower }}
33
33
 
34
34
  [usecli.commands]
35
- # Built-in commands to leave unregistered, for example ["inspire"].
35
+ # Built-in commands to leave unregistered for this project's CLI,
36
+ # for example ["inspire"]. The `usecli` framework binary always exposes
37
+ # its own built-in commands.
36
38
  hidden = []
37
39
 
38
40
  [usecli.upgrade]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes