usecli 0.1.65__tar.gz → 0.1.67__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 (70) hide show
  1. {usecli-0.1.65 → usecli-0.1.67}/PKG-INFO +1 -1
  2. {usecli-0.1.65 → usecli-0.1.67}/pyproject.toml +1 -1
  3. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/__init__.py +23 -7
  4. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/make/make_theme_command.py +2 -48
  5. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/shared/config/manager.py +19 -0
  6. {usecli-0.1.65 → usecli-0.1.67}/LICENSE +0 -0
  7. {usecli-0.1.65 → usecli-0.1.67}/README.md +0 -0
  8. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/__init__.py +0 -0
  9. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/README.md +0 -0
  10. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/__init__.py +0 -0
  11. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/custom/README.md +0 -0
  12. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/custom/__init__.py +0 -0
  13. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/__init__.py +0 -0
  14. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/base/__init__.py +0 -0
  15. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/base/about_command.py +0 -0
  16. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/base/help_command.py +0 -0
  17. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/base/inspire_command.py +0 -0
  18. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/base/internal/__init__.py +0 -0
  19. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/base/internal/fzf_command.py +0 -0
  20. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/core/__init__.py +0 -0
  21. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/core/utils.py +0 -0
  22. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/make/__init__.py +0 -0
  23. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/defaults/make/make_command.py +0 -0
  24. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/commands/init_command.py +0 -0
  25. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/config/__init__.py +0 -0
  26. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/config/colors.py +0 -0
  27. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/__init__.py +0 -0
  28. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/base_command.py +0 -0
  29. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/error/__init__.py +0 -0
  30. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/error/handler.py +0 -0
  31. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/error/utils.py +0 -0
  32. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/exceptions/__init__.py +0 -0
  33. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/exceptions/base.py +0 -0
  34. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/exceptions/config.py +0 -0
  35. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/exceptions/usage.py +0 -0
  36. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/exceptions/validation.py +0 -0
  37. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/ui/__init__.py +0 -0
  38. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/ui/list.py +0 -0
  39. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/ui/title.py +0 -0
  40. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/ui/title.txt +0 -0
  41. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/validators/__init__.py +0 -0
  42. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/validators/network.py +0 -0
  43. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/validators/numeric.py +0 -0
  44. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/validators/path.py +0 -0
  45. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/core/validators/string.py +0 -0
  46. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/services/__init__.py +0 -0
  47. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/services/command_service.py +0 -0
  48. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/templates/command.py.j2 +0 -0
  49. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/templates/theme.toml.j2 +0 -0
  50. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/templates/usecli.config.toml.j2 +0 -0
  51. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/ayu_dark.toml +0 -0
  52. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/catppuccin_frappe.toml +0 -0
  53. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/catppuccin_latte.toml +0 -0
  54. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/catppuccin_macchiato.toml +0 -0
  55. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/catppuccin_mocha.toml +0 -0
  56. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/default.toml +0 -0
  57. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/dracula.toml +0 -0
  58. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/gruvbox_dark.toml +0 -0
  59. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/nord.toml +0 -0
  60. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/themes/tokyo_night.toml +0 -0
  61. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/utils/__init__.py +0 -0
  62. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/utils/interactive/__init__.py +0 -0
  63. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/cli/utils/interactive/terminal_menu.py +0 -0
  64. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/menu.py +0 -0
  65. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/params.py +0 -0
  66. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/shared/__init__.py +0 -0
  67. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/shared/config/__init__.py +0 -0
  68. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/shared/config/globals.py +0 -0
  69. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/ui.py +0 -0
  70. {usecli-0.1.65 → usecli-0.1.67}/src/usecli/usecli.config.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: usecli
3
- Version: 0.1.65
3
+ Version: 0.1.67
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.1.65"
3
+ version = "0.1.67"
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" }]
@@ -165,25 +165,29 @@ def _ensure_cli_initialized() -> None:
165
165
  )
166
166
 
167
167
  def invoke(self, ctx):
168
- from click.exceptions import BadParameter, ClickException, Exit, UsageError
168
+ from click.exceptions import Exit
169
+
170
+ _TyperBadParameter = globals()["_TyperBadParameter"]
171
+ _TyperUsageError = globals()["_TyperUsageError"]
172
+ _TyperClickException = globals()["_TyperClickException"]
169
173
 
170
174
  try:
171
175
  return super().invoke(ctx)
172
176
  except Exit:
173
177
  sys.exit(0)
174
- except BadParameter as e:
178
+ except _TyperBadParameter as e:
175
179
  from usecli.cli.core.exceptions import UsecliBadParameter
176
180
 
177
181
  styled_error = UsecliBadParameter(e.message, ctx=e.ctx, param=e.param)
178
182
  styled_error.show()
179
183
  sys.exit(styled_error.exit_code)
180
- except UsageError as e:
184
+ except _TyperUsageError as e:
181
185
  from usecli.cli.core.exceptions import UsecliUsageError
182
186
 
183
187
  styled_error = UsecliUsageError(e.message, ctx=e.ctx)
184
188
  styled_error.show()
185
189
  sys.exit(styled_error.exit_code)
186
- except ClickException as e:
190
+ except _TyperClickException as e:
187
191
  if hasattr(e, "show"):
188
192
  e.show()
189
193
  sys.exit(e.exit_code if hasattr(e, "exit_code") else 1)
@@ -419,6 +423,12 @@ def main() -> None:
419
423
  _ensure_cli_initialized()
420
424
  _resolve_help()
421
425
 
426
+ # Use typer's exception classes if available (they're subclasses of click's)
427
+ # typer raises its own exceptions which may not match click's exactly
428
+ _TyperBadParameter = globals().get("_TyperBadParameter", BadParameter)
429
+ _TyperUsageError = globals().get("_TyperUsageError", UsageError)
430
+ _TyperClickException = globals().get("_TyperClickException", ClickException)
431
+
422
432
  from usecli.shared.config.manager import get_config
423
433
 
424
434
  config = get_config()
@@ -439,22 +449,28 @@ def main() -> None:
439
449
  _get_app()()
440
450
  except Exit:
441
451
  sys.exit(0)
442
- except BadParameter as e:
452
+ except _TyperBadParameter as e:
443
453
  from usecli.cli.core.exceptions import UsecliBadParameter
444
454
 
445
455
  styled_error = UsecliBadParameter(e.message, ctx=e.ctx, param=e.param)
446
456
  styled_error.show()
447
457
  sys.exit(styled_error.exit_code)
448
- except UsageError as e:
458
+ except _TyperUsageError as e:
449
459
  from usecli.cli.core.exceptions import UsecliUsageError
450
460
 
451
461
  styled_error = UsecliUsageError(e.message, ctx=e.ctx)
452
462
  styled_error.show()
453
463
  sys.exit(styled_error.exit_code)
454
- except ClickException as e:
464
+ except _TyperClickException as e:
455
465
  if hasattr(e, "show"):
456
466
  e.show()
457
467
  sys.exit(e.exit_code if hasattr(e, "exit_code") else 1)
468
+ except Exception as e:
469
+ from usecli.cli.core.exceptions import UsecliUsageError
470
+
471
+ styled_error = UsecliUsageError(str(e))
472
+ styled_error.show()
473
+ sys.exit(1)
458
474
 
459
475
 
460
476
  if __name__ == "__main__":
@@ -13,12 +13,7 @@ from rich.console import Console
13
13
  from usecli.cli.config.colors import COLOR
14
14
  from usecli.cli.core.base_command import BaseCommand
15
15
  from usecli.shared.config.globals import TEMPLATES_DIR
16
- from usecli.shared.config.manager import (
17
- ConfigManager,
18
- find_project_root,
19
- get_config,
20
- reset_config,
21
- )
16
+ from usecli.shared.config.manager import find_project_root, get_config, reset_config
22
17
 
23
18
  console = Console()
24
19
 
@@ -49,25 +44,7 @@ class MakeThemeCommand(BaseCommand):
49
44
  config = get_config()
50
45
 
51
46
  project_paths = config.get_project_paths()
52
- themes_entries = self._normalize_theme_entries(config.get("themes_dir", []))
53
- if not themes_entries:
54
- console.print(
55
- f"[{COLOR.ERROR}]Error: No theme directory configured.[/{COLOR.ERROR}]"
56
- )
57
- return
58
-
59
- default_entries = self._normalize_theme_entries(
60
- ConfigManager.DEFAULT_CONFIG.get("themes_dir", [])
61
- )
62
- preferred_entries = [
63
- entry for entry in themes_entries if entry not in default_entries
64
- ]
65
- if not preferred_entries:
66
- preferred_entries = themes_entries
67
-
68
- themes_dir = self._resolve_theme_dir(
69
- preferred_entries[0], config.get_project_root()
70
- )
47
+ themes_dir = project_paths["themes_dir"]
71
48
  themes_dir.mkdir(parents=True, exist_ok=True)
72
49
 
73
50
  base_name = Path(clean_name).name
@@ -103,26 +80,3 @@ class MakeThemeCommand(BaseCommand):
103
80
  console.print(
104
81
  f"[{COLOR.SUCCESS}]Successfully created theme at {target_file}[/{COLOR.SUCCESS}]"
105
82
  )
106
-
107
- @staticmethod
108
- def _normalize_theme_entries(value: object) -> list[str]:
109
- if isinstance(value, str):
110
- normalized = value.strip()
111
- return [normalized] if normalized else []
112
- if isinstance(value, list):
113
- result: list[str] = []
114
- for entry in value:
115
- if not isinstance(entry, str):
116
- continue
117
- normalized = entry.strip()
118
- if normalized:
119
- result.append(normalized)
120
- return result
121
- return []
122
-
123
- @staticmethod
124
- def _resolve_theme_dir(entry: str, project_root: Path) -> Path:
125
- theme_path = Path(entry)
126
- if not theme_path.is_absolute():
127
- theme_path = project_root / theme_path
128
- return theme_path.resolve()
@@ -856,9 +856,13 @@ class ConfigManager:
856
856
  def get_project_paths(self) -> dict[str, Path]:
857
857
  project_config = self._find_project_config()
858
858
  if project_config is None:
859
+ themes_dirs = self.get_project_themes_dirs()
859
860
  return {
860
861
  "commands_dir": self.get_project_commands_dir(),
861
862
  "templates_dir": self.get_project_templates_dir(),
863
+ "themes_dir": themes_dirs[0]
864
+ if themes_dirs
865
+ else self.get_project_root() / "cli" / "themes",
862
866
  }
863
867
  config_dir = project_config.parent
864
868
  config_data = self._load_usecli_toml(project_config)
@@ -870,9 +874,24 @@ class ConfigManager:
870
874
  commands_path = config_dir / commands_path
871
875
  if not templates_path.is_absolute():
872
876
  templates_path = config_dir / templates_path
877
+
878
+ themes_entries = _normalize_themes_dir(config_data.get("themes_dir", []))
879
+ if not themes_entries:
880
+ themes_entries = _normalize_themes_dir(
881
+ self.DEFAULT_CONFIG.get("themes_dir", [])
882
+ )
883
+ themes_path = (
884
+ _get_path()(themes_entries[0])
885
+ if themes_entries
886
+ else _get_path()("cli/themes")
887
+ )
888
+ if not themes_path.is_absolute():
889
+ themes_path = config_dir / themes_path
890
+
873
891
  return {
874
892
  "commands_dir": commands_path.resolve(),
875
893
  "templates_dir": templates_path.resolve(),
894
+ "themes_dir": themes_path.resolve(),
876
895
  }
877
896
 
878
897
  def _find_project_config(self) -> Path | None:
File without changes
File without changes
File without changes
File without changes
File without changes