usecli 0.2.1__tar.gz → 0.2.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.
- {usecli-0.2.1 → usecli-0.2.2}/PKG-INFO +1 -1
- {usecli-0.2.1 → usecli-0.2.2}/pyproject.toml +1 -1
- {usecli-0.2.1 → usecli-0.2.2}/pyproject.toml.orig +1 -1
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/__init__.py +2 -3
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/base/about_command.py +6 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/ui/title.py +96 -13
- {usecli-0.2.1 → usecli-0.2.2}/LICENSE +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/README.md +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/bundler/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/bundler/__main__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/README.md +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/custom/README.md +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/custom/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/base/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/base/help_command.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/base/inspire_command.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/base/internal/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/base/internal/interactive_command.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/base/upgrade_command.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/core/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/core/utils.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/make/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/make/make_bundle_command.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/make/make_command.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/make/make_theme_command.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/init_command.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/config/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/config/colors.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/_typer_compat.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/base_command.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/error/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/error/handler.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/error/utils.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/exceptions/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/exceptions/base.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/exceptions/config.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/exceptions/usage.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/exceptions/validation.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/runtime.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/ui/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/ui/list.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/ui/title.txt +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/validators/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/validators/network.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/validators/numeric.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/validators/path.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/core/validators/string.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/services/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/services/command_service.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/templates/command.py.j2 +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/templates/theme.toml.j2 +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/templates/usecli.config.toml.j2 +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/ayu_dark.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/catppuccin_frappe.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/catppuccin_latte.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/catppuccin_macchiato.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/catppuccin_mocha.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/default.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/dracula.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/gruvbox_dark.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/nord.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/themes/tokyo_night.toml +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/utils/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/utils/interactive/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/utils/interactive/prompt_input.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/utils/interactive/terminal_menu.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/entry.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/menu.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/params.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/progress.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/config/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/config/globals.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/config/manager.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/upgrades/__init__.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/upgrades/checker.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/upgrades/discovery.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/upgrades/installer.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/upgrades/pyproject.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/upgrades/service.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/shared/upgrades/settings.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/ui.py +0 -0
- {usecli-0.2.1 → usecli-0.2.2}/src/usecli/usecli.config.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "usecli"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.2"
|
|
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.
|
|
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}]{
|
|
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,66 @@ 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
|
+
|
|
17
79
|
|
|
18
80
|
def _get_script_command_name(start_dir: Path | None = None) -> str | None:
|
|
19
81
|
if start_dir is None:
|
|
@@ -44,6 +106,14 @@ def _get_script_command_name(start_dir: Path | None = None) -> str | None:
|
|
|
44
106
|
|
|
45
107
|
|
|
46
108
|
def get_script_command_name(default: str | None = None) -> str | None:
|
|
109
|
+
"""Get the command name used in usage lines and error messages.
|
|
110
|
+
|
|
111
|
+
The usecli binary reports itself, not the project's CLI name: a user who
|
|
112
|
+
typed ``usecli`` must see ``usecli`` in usage output.
|
|
113
|
+
"""
|
|
114
|
+
if _running_framework_distribution() is not None:
|
|
115
|
+
return "usecli"
|
|
116
|
+
|
|
47
117
|
config = get_config()
|
|
48
118
|
config_command_name = config.get("command_name")
|
|
49
119
|
if config.has_key("command_name") and config_command_name:
|
|
@@ -60,7 +130,14 @@ def get_script_command_name(default: str | None = None) -> str | None:
|
|
|
60
130
|
|
|
61
131
|
|
|
62
132
|
def get_project_name() -> str:
|
|
63
|
-
"""Get the
|
|
133
|
+
"""Get the display name of the running CLI.
|
|
134
|
+
|
|
135
|
+
The usecli binary reports the framework name; downstream CLIs report the
|
|
136
|
+
title configured for their project.
|
|
137
|
+
"""
|
|
138
|
+
if _running_framework_distribution() is not None:
|
|
139
|
+
return "useCli"
|
|
140
|
+
|
|
64
141
|
# First, try to get the title from the config
|
|
65
142
|
config = get_config()
|
|
66
143
|
title = config.get("title")
|
|
@@ -111,21 +188,23 @@ def render_figlet_title(figlet: Any, text: str, font: str) -> str:
|
|
|
111
188
|
def get_project_version() -> str | None:
|
|
112
189
|
"""Best-effort version of the running CLI.
|
|
113
190
|
|
|
114
|
-
|
|
115
|
-
|
|
191
|
+
The usecli binary reports the installed framework version. A downstream
|
|
192
|
+
CLI resolves the distribution that owns the invoked console script first,
|
|
193
|
+
then falls back to ``[project].version`` in the project's pyproject.toml.
|
|
116
194
|
"""
|
|
195
|
+
framework_dist = _running_framework_distribution()
|
|
196
|
+
if framework_dist is not None:
|
|
197
|
+
return _distribution_version(framework_dist)
|
|
198
|
+
|
|
117
199
|
command_name = get_script_command_name()
|
|
118
200
|
if command_name:
|
|
119
201
|
from usecli.shared.config.manager import _find_distribution_for_console_script
|
|
120
202
|
|
|
121
203
|
dist = _find_distribution_for_console_script(command_name)
|
|
122
204
|
if dist is not None:
|
|
123
|
-
|
|
124
|
-
version = dist.version
|
|
125
|
-
except (AttributeError, OSError, TypeError):
|
|
126
|
-
version = None
|
|
205
|
+
version = _distribution_version(dist)
|
|
127
206
|
if version:
|
|
128
|
-
return
|
|
207
|
+
return version
|
|
129
208
|
|
|
130
209
|
try:
|
|
131
210
|
return get_config().get_project_version()
|
|
@@ -197,11 +276,15 @@ def print_title(title: str | None = None) -> None:
|
|
|
197
276
|
if config.has_key("banner.show_description")
|
|
198
277
|
else not (figlet is not None and bool(title_font))
|
|
199
278
|
)
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
279
|
+
framework_description = get_framework_description()
|
|
280
|
+
if show_description and framework_description:
|
|
281
|
+
description = framework_description
|
|
282
|
+
else:
|
|
283
|
+
description = (
|
|
284
|
+
config.get("description")
|
|
285
|
+
if show_description and config.has_key("description")
|
|
286
|
+
else None
|
|
287
|
+
)
|
|
205
288
|
show_version = (
|
|
206
289
|
bool(config.get("banner.show_version"))
|
|
207
290
|
if config.has_key("banner.show_version")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{usecli-0.2.1 → usecli-0.2.2}/src/usecli/cli/commands/defaults/base/internal/interactive_command.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|