usecli 0.2.1__tar.gz → 0.2.3__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.1 → usecli-0.2.3}/PKG-INFO +1 -1
  2. {usecli-0.2.1 → usecli-0.2.3}/pyproject.toml +1 -1
  3. {usecli-0.2.1 → usecli-0.2.3}/pyproject.toml.orig +1 -1
  4. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/__init__.py +2 -3
  5. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/base/about_command.py +6 -0
  6. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/ui/title.py +129 -15
  7. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/services/command_service.py +4 -0
  8. {usecli-0.2.1 → usecli-0.2.3}/LICENSE +0 -0
  9. {usecli-0.2.1 → usecli-0.2.3}/README.md +0 -0
  10. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/bundler/__init__.py +0 -0
  11. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/bundler/__main__.py +0 -0
  12. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/__init__.py +0 -0
  13. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/README.md +0 -0
  14. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/__init__.py +0 -0
  15. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/custom/README.md +0 -0
  16. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/custom/__init__.py +0 -0
  17. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/__init__.py +0 -0
  18. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/base/__init__.py +0 -0
  19. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/base/help_command.py +0 -0
  20. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/base/inspire_command.py +0 -0
  21. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/base/internal/__init__.py +0 -0
  22. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/base/internal/interactive_command.py +0 -0
  23. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/base/upgrade_command.py +0 -0
  24. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/core/__init__.py +0 -0
  25. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/core/utils.py +0 -0
  26. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/make/__init__.py +0 -0
  27. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/make/make_bundle_command.py +0 -0
  28. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/make/make_command.py +0 -0
  29. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/defaults/make/make_theme_command.py +0 -0
  30. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/commands/init_command.py +0 -0
  31. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/config/__init__.py +0 -0
  32. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/config/colors.py +0 -0
  33. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/__init__.py +0 -0
  34. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/_typer_compat.py +0 -0
  35. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/base_command.py +0 -0
  36. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/error/__init__.py +0 -0
  37. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/error/handler.py +0 -0
  38. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/error/utils.py +0 -0
  39. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/exceptions/__init__.py +0 -0
  40. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/exceptions/base.py +0 -0
  41. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/exceptions/config.py +0 -0
  42. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/exceptions/usage.py +0 -0
  43. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/exceptions/validation.py +0 -0
  44. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/runtime.py +0 -0
  45. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/ui/__init__.py +0 -0
  46. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/ui/list.py +0 -0
  47. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/ui/title.txt +0 -0
  48. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/validators/__init__.py +0 -0
  49. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/validators/network.py +0 -0
  50. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/validators/numeric.py +0 -0
  51. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/validators/path.py +0 -0
  52. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/core/validators/string.py +0 -0
  53. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/services/__init__.py +0 -0
  54. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/templates/command.py.j2 +0 -0
  55. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/templates/theme.toml.j2 +0 -0
  56. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/templates/usecli.config.toml.j2 +0 -0
  57. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/ayu_dark.toml +0 -0
  58. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/catppuccin_frappe.toml +0 -0
  59. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/catppuccin_latte.toml +0 -0
  60. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/catppuccin_macchiato.toml +0 -0
  61. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/catppuccin_mocha.toml +0 -0
  62. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/default.toml +0 -0
  63. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/dracula.toml +0 -0
  64. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/gruvbox_dark.toml +0 -0
  65. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/nord.toml +0 -0
  66. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/themes/tokyo_night.toml +0 -0
  67. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/utils/__init__.py +0 -0
  68. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/utils/interactive/__init__.py +0 -0
  69. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/utils/interactive/prompt_input.py +0 -0
  70. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/cli/utils/interactive/terminal_menu.py +0 -0
  71. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/entry.py +0 -0
  72. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/menu.py +0 -0
  73. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/params.py +0 -0
  74. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/progress.py +0 -0
  75. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/__init__.py +0 -0
  76. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/config/__init__.py +0 -0
  77. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/config/globals.py +0 -0
  78. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/config/manager.py +0 -0
  79. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/upgrades/__init__.py +0 -0
  80. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/upgrades/checker.py +0 -0
  81. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/upgrades/discovery.py +0 -0
  82. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/upgrades/installer.py +0 -0
  83. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/upgrades/pyproject.py +0 -0
  84. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/upgrades/service.py +0 -0
  85. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/shared/upgrades/settings.py +0 -0
  86. {usecli-0.2.1 → usecli-0.2.3}/src/usecli/ui.py +0 -0
  87. {usecli-0.2.1 → usecli-0.2.3}/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.1
3
+ Version: 0.2.3
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.1"
3
+ version = "0.2.3"
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.1"
3
+ version = "0.2.3"
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" }]
@@ -552,13 +552,12 @@ def _get_run_app_callback():
552
552
  if version:
553
553
  import shutil
554
554
 
555
- from usecli.shared.config.manager import get_config
555
+ from usecli.cli.core.ui.title import get_project_name
556
556
 
557
- config = get_config()
558
557
  service = _get_service()
559
558
  command_path = shutil.which(sys.argv[0]) or sys.argv[0]
560
559
  _console().print(
561
- f"[bold {globals()['theme'].SECONDARY}]{config.get('title')} {service.version}[/bold {globals()['theme'].SECONDARY}] [{globals()['theme'].INFO}]({command_path})[/{globals()['theme'].INFO}]"
560
+ f"[bold {globals()['theme'].SECONDARY}]{get_project_name()} {service.version}[/bold {globals()['theme'].SECONDARY}] [{globals()['theme'].INFO}]({command_path})[/{globals()['theme'].INFO}]"
562
561
  )
563
562
  raise typer.Exit()
564
563
 
@@ -144,6 +144,12 @@ def _get_application_version(config) -> str:
144
144
 
145
145
 
146
146
  def _get_application_description(config) -> str:
147
+ from usecli.cli.core.ui.title import get_framework_description
148
+
149
+ framework_description = get_framework_description()
150
+ if framework_description:
151
+ return framework_description
152
+
147
153
  description = config.get("description")
148
154
  if (
149
155
  config.has_key("description")
@@ -2,6 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import os
6
+ import sys
5
7
  import tomllib
6
8
  from importlib.metadata import PackageNotFoundError, metadata
7
9
  from pathlib import Path
@@ -14,6 +16,80 @@ from usecli.shared.config.manager import get_config
14
16
 
15
17
  console = Console()
16
18
 
19
+ _FRAMEWORK_DIST_NAME = "usecli"
20
+
21
+ # argv0 values set by the interpreter rather than by a console script.
22
+ _NON_SCRIPT_ARGV0 = frozenset({"-c", "-m", "__main__.py"})
23
+
24
+
25
+ def _invoked_script_name() -> str | None:
26
+ """Return the console-script name this process was started as."""
27
+ if not sys.argv:
28
+ return None
29
+ name = os.path.basename(sys.argv[0])
30
+ if not name or name in _NON_SCRIPT_ARGV0:
31
+ return None
32
+ return name
33
+
34
+
35
+ def _running_framework_distribution() -> Any | None:
36
+ """Return the usecli distribution when running as one of its console scripts.
37
+
38
+ The invoked console script decides the process identity: ``usecli`` (or
39
+ ``usecli-bundle``) means the framework binary is running, so banners must
40
+ describe the framework rather than the project it scaffolds.
41
+ """
42
+ script_name = _invoked_script_name()
43
+ if script_name is None:
44
+ return None
45
+
46
+ from usecli.shared.config.manager import _find_distribution_for_console_script
47
+
48
+ dist = _find_distribution_for_console_script(script_name)
49
+ if dist is None:
50
+ return None
51
+ dist_metadata = getattr(dist, "metadata", None)
52
+ if dist_metadata is None:
53
+ return None
54
+ dist_name = dist_metadata.get("Name") or ""
55
+ return dist if str(dist_name).strip().lower() == _FRAMEWORK_DIST_NAME else None
56
+
57
+
58
+ def _distribution_version(dist: Any) -> str | None:
59
+ try:
60
+ version = dist.version
61
+ except (AttributeError, OSError, TypeError):
62
+ return None
63
+ return str(version) if version else None
64
+
65
+
66
+ def get_framework_description() -> str | None:
67
+ """Description of the usecli distribution when running the framework binary.
68
+
69
+ Returns ``None`` for downstream CLIs, whose config description owns the
70
+ banner.
71
+ """
72
+ dist = _running_framework_distribution()
73
+ if dist is None:
74
+ return None
75
+ summary = dist.metadata.get("Summary")
76
+ summary = summary.strip() if isinstance(summary, str) else ""
77
+ return summary or None
78
+
79
+
80
+ def _strip_blank_edges(text: str) -> str:
81
+ """Drop whitespace-only lines above and below rendered art.
82
+
83
+ Banner spacing belongs to ``banner.top_space``/``banner.bottom_space``;
84
+ literal blank lines baked into art would double it.
85
+ """
86
+ lines = text.split("\n")
87
+ while lines and not lines[0].strip():
88
+ lines.pop(0)
89
+ while lines and not lines[-1].strip():
90
+ lines.pop()
91
+ return "\n".join(lines)
92
+
17
93
 
18
94
  def _get_script_command_name(start_dir: Path | None = None) -> str | None:
19
95
  if start_dir is None:
@@ -44,6 +120,14 @@ def _get_script_command_name(start_dir: Path | None = None) -> str | None:
44
120
 
45
121
 
46
122
  def get_script_command_name(default: str | None = None) -> str | None:
123
+ """Get the command name used in usage lines and error messages.
124
+
125
+ The usecli binary reports itself, not the project's CLI name: a user who
126
+ typed ``usecli`` must see ``usecli`` in usage output.
127
+ """
128
+ if _running_framework_distribution() is not None:
129
+ return "usecli"
130
+
47
131
  config = get_config()
48
132
  config_command_name = config.get("command_name")
49
133
  if config.has_key("command_name") and config_command_name:
@@ -60,7 +144,14 @@ def get_script_command_name(default: str | None = None) -> str | None:
60
144
 
61
145
 
62
146
  def get_project_name() -> str:
63
- """Get the project name from config or package metadata."""
147
+ """Get the display name of the running CLI.
148
+
149
+ The usecli binary reports the framework name; downstream CLIs report the
150
+ title configured for their project.
151
+ """
152
+ if _running_framework_distribution() is not None:
153
+ return "useCli"
154
+
64
155
  # First, try to get the title from the config
65
156
  config = get_config()
66
157
  title = config.get("title")
@@ -111,21 +202,23 @@ def render_figlet_title(figlet: Any, text: str, font: str) -> str:
111
202
  def get_project_version() -> str | None:
112
203
  """Best-effort version of the running CLI.
113
204
 
114
- Resolves the distribution that owns the invoked console script first, then
115
- falls back to ``[project].version`` in the project's pyproject.toml.
205
+ The usecli binary reports the installed framework version. A downstream
206
+ CLI resolves the distribution that owns the invoked console script first,
207
+ then falls back to ``[project].version`` in the project's pyproject.toml.
116
208
  """
209
+ framework_dist = _running_framework_distribution()
210
+ if framework_dist is not None:
211
+ return _distribution_version(framework_dist)
212
+
117
213
  command_name = get_script_command_name()
118
214
  if command_name:
119
215
  from usecli.shared.config.manager import _find_distribution_for_console_script
120
216
 
121
217
  dist = _find_distribution_for_console_script(command_name)
122
218
  if dist is not None:
123
- try:
124
- version = dist.version
125
- except (AttributeError, OSError, TypeError):
126
- version = None
219
+ version = _distribution_version(dist)
127
220
  if version:
128
- return str(version)
221
+ return version
129
222
 
130
223
  try:
131
224
  return get_config().get_project_version()
@@ -133,6 +226,23 @@ def get_project_version() -> str | None:
133
226
  return None
134
227
 
135
228
 
229
+ def _banner_config():
230
+ """Config that owns the banner layout.
231
+
232
+ The usecli binary renders the framework banner, so its layout (file, font,
233
+ spacing, show flags) comes from the installed framework config rather than
234
+ the downstream project being scaffolded. Downstream CLIs keep using the
235
+ discovered project config.
236
+ """
237
+ if _running_framework_distribution() is None:
238
+ return get_config()
239
+
240
+ from usecli.shared.config.globals import PACKAGE_ROOT
241
+ from usecli.shared.config.manager import ConfigManager
242
+
243
+ return ConfigManager(start_dir=PACKAGE_ROOT)
244
+
245
+
136
246
  def render_plain_title(
137
247
  title: str,
138
248
  description: str | None = None,
@@ -186,7 +296,7 @@ def print_title(title: str | None = None) -> None:
186
296
 
187
297
  █████▓▓▓▓▓▒▒▒▒▒░░░░░░░░░░░░░░▒▒▒▒▒▓▓▓▓▓█████
188
298
  """
189
- config = get_config()
299
+ config = _banner_config()
190
300
 
191
301
  top_space = config.get("banner.top_space", True)
192
302
  bottom_space = config.get("banner.bottom_space", True)
@@ -197,11 +307,15 @@ def print_title(title: str | None = None) -> None:
197
307
  if config.has_key("banner.show_description")
198
308
  else not (figlet is not None and bool(title_font))
199
309
  )
200
- description = (
201
- config.get("description")
202
- if show_description and config.has_key("description")
203
- else None
204
- )
310
+ framework_description = get_framework_description()
311
+ if show_description and framework_description:
312
+ description = framework_description
313
+ else:
314
+ description = (
315
+ config.get("description")
316
+ if show_description and config.has_key("description")
317
+ else None
318
+ )
205
319
  show_version = (
206
320
  bool(config.get("banner.show_version"))
207
321
  if config.has_key("banner.show_version")
@@ -230,7 +344,7 @@ def print_title(title: str | None = None) -> None:
230
344
  pass
231
345
 
232
346
  if title is None or title.lower() == "usecli":
233
- console.print(f"[{COLOR.PRIMARY}]{default_title_text}")
347
+ console.print(f"[{COLOR.PRIMARY}]{_strip_blank_edges(default_title_text)}")
234
348
  if bottom_space:
235
349
  console.print()
236
350
  return
@@ -70,6 +70,10 @@ class CommandService:
70
70
  project_commands_dir.relative_to(package_commands_dir)
71
71
  return
72
72
  except ValueError:
73
+ if command_name == "usecli":
74
+ # The framework binary exposes the framework's commands only;
75
+ # project commands belong to the project's own CLI.
76
+ return
73
77
  self._load_from_dir(project_commands_dir)
74
78
 
75
79
  def _load_version(self) -> None:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes