usecli 0.2.3__tar.gz → 0.2.4__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.3 → usecli-0.2.4}/PKG-INFO +1 -1
- {usecli-0.2.3 → usecli-0.2.4}/pyproject.toml +1 -1
- {usecli-0.2.3 → usecli-0.2.4}/pyproject.toml.orig +1 -1
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/base/internal/interactive_command.py +42 -39
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/_typer_compat.py +21 -0
- {usecli-0.2.3 → usecli-0.2.4}/LICENSE +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/README.md +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/bundler/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/bundler/__main__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/README.md +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/custom/README.md +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/custom/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/base/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/base/about_command.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/base/help_command.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/base/inspire_command.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/base/internal/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/base/upgrade_command.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/core/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/core/utils.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/make/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/make/make_bundle_command.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/make/make_command.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/make/make_theme_command.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/init_command.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/config/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/config/colors.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/base_command.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/error/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/error/handler.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/error/utils.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/exceptions/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/exceptions/base.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/exceptions/config.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/exceptions/usage.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/exceptions/validation.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/runtime.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/ui/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/ui/list.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/ui/title.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/ui/title.txt +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/validators/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/validators/network.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/validators/numeric.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/validators/path.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/core/validators/string.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/services/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/services/command_service.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/templates/command.py.j2 +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/templates/theme.toml.j2 +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/templates/usecli.config.toml.j2 +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/ayu_dark.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/catppuccin_frappe.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/catppuccin_latte.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/catppuccin_macchiato.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/catppuccin_mocha.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/default.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/dracula.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/gruvbox_dark.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/nord.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/themes/tokyo_night.toml +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/utils/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/utils/interactive/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/utils/interactive/prompt_input.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/utils/interactive/terminal_menu.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/entry.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/menu.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/params.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/progress.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/config/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/config/globals.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/config/manager.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/upgrades/__init__.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/upgrades/checker.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/upgrades/discovery.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/upgrades/installer.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/upgrades/pyproject.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/upgrades/service.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/shared/upgrades/settings.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/src/usecli/ui.py +0 -0
- {usecli-0.2.3 → usecli-0.2.4}/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.4"
|
|
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" }]
|
{usecli-0.2.3 → usecli-0.2.4}/src/usecli/cli/commands/defaults/base/internal/interactive_command.py
RENAMED
|
@@ -283,6 +283,33 @@ def _get_group_subcommands(
|
|
|
283
283
|
return subcommands
|
|
284
284
|
|
|
285
285
|
|
|
286
|
+
def _prompt_for_text(prompt_text: str, empty_message: str) -> str:
|
|
287
|
+
"""Read a non-empty value through rich's prompt-toolkit input seam.
|
|
288
|
+
|
|
289
|
+
``console.input`` is patched by
|
|
290
|
+
:func:`usecli.cli.utils.interactive.prompt_input.install_prompt_input`, so
|
|
291
|
+
cursor keys, editing and history work instead of reaching a raw
|
|
292
|
+
``input()``.
|
|
293
|
+
"""
|
|
294
|
+
value = ""
|
|
295
|
+
while not value:
|
|
296
|
+
try:
|
|
297
|
+
value = console.input(
|
|
298
|
+
f"[bold {COLOR.SECONDARY}]{prompt_text}[/bold {COLOR.SECONDARY}]\n"
|
|
299
|
+
f"[bold {COLOR.SECONDARY}]└─> [/bold {COLOR.SECONDARY}]"
|
|
300
|
+
).strip()
|
|
301
|
+
except EOFError:
|
|
302
|
+
value = ""
|
|
303
|
+
except KeyboardInterrupt:
|
|
304
|
+
ErrorHandler.display_warning("Cancelled by user")
|
|
305
|
+
raise typer.Exit(code=0)
|
|
306
|
+
|
|
307
|
+
if not value:
|
|
308
|
+
console.print(f"[{COLOR.ERROR}]{empty_message}[/{COLOR.ERROR}]")
|
|
309
|
+
|
|
310
|
+
return value
|
|
311
|
+
|
|
312
|
+
|
|
286
313
|
def run_interactive(
|
|
287
314
|
app: typer.Typer,
|
|
288
315
|
cmd_parts: list[str] | None = None,
|
|
@@ -457,28 +484,13 @@ def run_interactive(
|
|
|
457
484
|
)
|
|
458
485
|
value = str(int_value)
|
|
459
486
|
else:
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
prompt_text
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
prompt_text
|
|
466
|
-
|
|
467
|
-
console.print(f"[bold {COLOR.SECONDARY}]└─> ", end="")
|
|
468
|
-
|
|
469
|
-
try:
|
|
470
|
-
user_input = input()
|
|
471
|
-
value = user_input.strip()
|
|
472
|
-
except EOFError:
|
|
473
|
-
value = ""
|
|
474
|
-
except KeyboardInterrupt:
|
|
475
|
-
ErrorHandler.display_warning("Cancelled by user")
|
|
476
|
-
raise typer.Exit(code=0)
|
|
477
|
-
|
|
478
|
-
if not value:
|
|
479
|
-
console.print(
|
|
480
|
-
f"[{COLOR.ERROR}]Value is required. Please enter a value.[/{COLOR.ERROR}]"
|
|
481
|
-
)
|
|
487
|
+
prompt_text = f"Enter value for '{arg_name}'"
|
|
488
|
+
if arg_help:
|
|
489
|
+
prompt_text += f" ({arg_help})"
|
|
490
|
+
prompt_text += ":"
|
|
491
|
+
value = _prompt_for_text(
|
|
492
|
+
prompt_text, "Value is required. Please enter a value."
|
|
493
|
+
)
|
|
482
494
|
|
|
483
495
|
if " " in value:
|
|
484
496
|
value = f'"{value}"'
|
|
@@ -555,23 +567,14 @@ def run_interactive(
|
|
|
555
567
|
)
|
|
556
568
|
option_values.append(f"{first_flag} {int_value}")
|
|
557
569
|
else:
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
prompt_text
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
prompt_text
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
try:
|
|
567
|
-
opt_value = input().strip()
|
|
568
|
-
except KeyboardInterrupt:
|
|
569
|
-
ErrorHandler.display_warning("Cancelled by user")
|
|
570
|
-
raise typer.Exit(code=0)
|
|
571
|
-
if not opt_value:
|
|
572
|
-
console.print(
|
|
573
|
-
f"[{COLOR.ERROR}]Value is required. Please enter a value or press Ctrl+C to cancel.[/{COLOR.ERROR}]"
|
|
574
|
-
)
|
|
570
|
+
prompt_text = f"Value for {first_flag}"
|
|
571
|
+
if help_text:
|
|
572
|
+
prompt_text += f" ({help_text})"
|
|
573
|
+
prompt_text += ":"
|
|
574
|
+
opt_value = _prompt_for_text(
|
|
575
|
+
prompt_text,
|
|
576
|
+
"Value is required. Please enter a value or press Ctrl+C to cancel.",
|
|
577
|
+
)
|
|
575
578
|
if " " in opt_value:
|
|
576
579
|
opt_value = f'"{opt_value}"'
|
|
577
580
|
option_values.append(f"{first_flag} {opt_value}")
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
Typer >= 0.28 replaced ``TyperOption``'s ``type`` argument with a required
|
|
4
4
|
``type_descriptor``. usecli builds options directly to inject framework-wide
|
|
5
5
|
flags, so it must support both layouts.
|
|
6
|
+
|
|
7
|
+
Typer also vendors its own click, whose parameter classes predate click's
|
|
8
|
+
``get_error_hint(ctx)`` signature. usecli formats typer parameters with
|
|
9
|
+
click's exception classes, so the hint methods are adapted below.
|
|
6
10
|
"""
|
|
7
11
|
|
|
8
12
|
from __future__ import annotations
|
|
9
13
|
|
|
14
|
+
import functools
|
|
10
15
|
import inspect
|
|
11
16
|
from typing import Any
|
|
12
17
|
|
|
@@ -17,6 +22,22 @@ _HAS_TYPE_DESCRIPTOR = (
|
|
|
17
22
|
)
|
|
18
23
|
|
|
19
24
|
|
|
25
|
+
def _accept_click_ctx(method: Any) -> Any:
|
|
26
|
+
"""Let click pass its context to a typer parameter's error hint method."""
|
|
27
|
+
if "ctx" in inspect.signature(method).parameters:
|
|
28
|
+
return method
|
|
29
|
+
|
|
30
|
+
@functools.wraps(method)
|
|
31
|
+
def get_error_hint(self: Any, ctx: Any = None) -> str:
|
|
32
|
+
return method(self)
|
|
33
|
+
|
|
34
|
+
return get_error_hint
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
TyperArgument.get_error_hint = _accept_click_ctx(TyperArgument.get_error_hint)
|
|
38
|
+
TyperOption.get_error_hint = _accept_click_ctx(TyperOption.get_error_hint)
|
|
39
|
+
|
|
40
|
+
|
|
20
41
|
def _type_descriptor(annotation: type, *, argument: bool = False) -> Any:
|
|
21
42
|
from typer._coercion import resolve_type_descriptor
|
|
22
43
|
from typer.models import ArgumentInfo, OptionInfo
|
|
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
|
|
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
|