womm-cli 4.0.0__py3-none-any.whl
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.
- womm/__init__.py +53 -0
- womm/__main__.py +48 -0
- womm/_version.py +10 -0
- womm/assets/copier/meta/copier.yml +15 -0
- womm/assets/copier/meta/template/README.md.jinja +32 -0
- womm/assets/copier/meta/template/copier.yml.jinja +13 -0
- womm/assets/copier/meta/template/template/.gitkeep +0 -0
- womm/assets/copier/official/javascript/copier.yml +104 -0
- womm/assets/copier/official/javascript/template/.gitignore.jinja +35 -0
- womm/assets/copier/official/javascript/template/.nvmrc.jinja +1 -0
- womm/assets/copier/official/javascript/template/.prettierignore.jinja +10 -0
- womm/assets/copier/official/javascript/template/README.md.jinja +81 -0
- womm/assets/copier/official/javascript/template/biome.json.jinja +54 -0
- womm/assets/copier/official/javascript/template/eslint.config.mjs.jinja +51 -0
- womm/assets/copier/official/javascript/template/index.html.jinja +12 -0
- womm/assets/copier/official/javascript/template/package.json.jinja +88 -0
- womm/assets/copier/official/javascript/template/prettier.config.mjs.jinja +8 -0
- womm/assets/copier/official/javascript/template/src/App.jsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/App.tsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/App.vue.jinja +18 -0
- womm/assets/copier/official/javascript/template/src/index.jsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/index.tsx.jinja +11 -0
- womm/assets/copier/official/javascript/template/src/main.js.jinja +21 -0
- womm/assets/copier/official/javascript/template/src/main.ts.jinja +21 -0
- womm/assets/copier/official/javascript/template/tsconfig.json.jinja +35 -0
- womm/assets/copier/official/javascript/template/vite.config.mjs.jinja +10 -0
- womm/assets/copier/official/javascript/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +63 -0
- womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.js.jinja +12 -0
- womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.ts.jinja +12 -0
- womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +4 -0
- womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +27 -0
- womm/assets/copier/official/python/copier.yml +107 -0
- womm/assets/copier/official/python/template/.gitignore.jinja +40 -0
- womm/assets/copier/official/python/template/.pre-commit-config.yaml.jinja +19 -0
- womm/assets/copier/official/python/template/.python-version.jinja +1 -0
- womm/assets/copier/official/python/template/README.md.jinja +83 -0
- womm/assets/copier/official/python/template/pyproject.toml.jinja +114 -0
- womm/assets/copier/official/python/template/{% if framework == 'django' %}manage.py{% endif %}.jinja +23 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/__init__.py.jinja +3 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/asgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/__init__.py.jinja +0 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/apps.py.jinja +10 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/models.py.jinja +1 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/views.py.jinja +8 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/py.typed +0 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/settings.py.jinja +81 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/urls.py.jinja +11 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/wsgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/__init__.py.jinja +3 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/asgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/__init__.py.jinja +0 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/apps.py.jinja +10 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/models.py.jinja +1 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/views.py.jinja +8 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/py.typed +0 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/settings.py.jinja +81 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/urls.py.jinja +11 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/wsgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +78 -0
- womm/assets/copier/official/python/template/{% if with_tests %}tests{% endif %}/test_smoke.py.jinja +16 -0
- womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +8 -0
- womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +28 -0
- womm/bin/refresh_env.cmd +130 -0
- womm/cli.py +111 -0
- womm/commands/__init__.py +30 -0
- womm/commands/core/__init__.py +29 -0
- womm/commands/core/doctor.py +52 -0
- womm/commands/core/path.py +337 -0
- womm/commands/project/__init__.py +31 -0
- womm/commands/project/create.py +128 -0
- womm/commands/project/setup.py +438 -0
- womm/commands/project/template.py +160 -0
- womm/commands/system/__init__.py +31 -0
- womm/commands/system/context/__init__.py +82 -0
- womm/commands/system/context/backup.py +344 -0
- womm/commands/system/context/inventory.py +111 -0
- womm/commands/system/context/registration.py +290 -0
- womm/commands/system/deps.py +165 -0
- womm/commands/system/system.py +130 -0
- womm/exceptions/__init__.py +69 -0
- womm/exceptions/common/__init__.py +55 -0
- womm/exceptions/common/command_service.py +91 -0
- womm/exceptions/common/file_service.py +60 -0
- womm/exceptions/common/security_service.py +44 -0
- womm/exceptions/common/validation_service.py +70 -0
- womm/exceptions/context/__init__.py +27 -0
- womm/exceptions/context/context_service.py +55 -0
- womm/exceptions/project/__init__.py +29 -0
- womm/exceptions/project/project_service.py +59 -0
- womm/exceptions/system/__init__.py +25 -0
- womm/exceptions/system/system_service.py +53 -0
- womm/interfaces/__init__.py +71 -0
- womm/interfaces/context/__init__.py +34 -0
- womm/interfaces/context/menu_interface.py +686 -0
- womm/interfaces/context/registry_interface.py +562 -0
- womm/interfaces/context/script_detector_interface.py +208 -0
- womm/interfaces/context/script_registrar.py +264 -0
- womm/interfaces/core/__init__.py +26 -0
- womm/interfaces/core/doctor_interface.py +102 -0
- womm/interfaces/dependencies/__init__.py +28 -0
- womm/interfaces/dependencies/deps_interface.py +160 -0
- womm/interfaces/project/__init__.py +36 -0
- womm/interfaces/project/create_interface.py +162 -0
- womm/interfaces/project/detection_interface.py +181 -0
- womm/interfaces/project/manager_interface.py +99 -0
- womm/interfaces/project/setup_interface.py +477 -0
- womm/interfaces/project/template_store_interface.py +196 -0
- womm/interfaces/system/__init__.py +32 -0
- womm/interfaces/system/detector_interface.py +84 -0
- womm/interfaces/system/environment_interface.py +110 -0
- womm/interfaces/system/path_interface.py +570 -0
- womm/services/__init__.py +70 -0
- womm/services/common/__init__.py +33 -0
- womm/services/common/base_validation_service.py +450 -0
- womm/services/common/command_runner_service.py +647 -0
- womm/services/common/file_scanner_service.py +483 -0
- womm/services/common/security_validator_service.py +348 -0
- womm/services/context/__init__.py +37 -0
- womm/services/context/backup_entries.py +148 -0
- womm/services/context/parameters.py +515 -0
- womm/services/context/registry_paths.py +56 -0
- womm/services/context/registry_service.py +573 -0
- womm/services/context/validation_service.py +691 -0
- womm/services/dependencies/__init__.py +29 -0
- womm/services/dependencies/probe.py +102 -0
- womm/services/project/__init__.py +48 -0
- womm/services/project/copier_project_creation_service.py +111 -0
- womm/services/project/destination_guard.py +96 -0
- womm/services/project/detection_service.py +354 -0
- womm/services/project/env_utils.py +333 -0
- womm/services/project/javascript_environment_service.py +348 -0
- womm/services/project/python_environment_service.py +245 -0
- womm/services/project/setup_profile_resolver.py +146 -0
- womm/services/project/template_store_service.py +344 -0
- womm/services/project/validation_service.py +418 -0
- womm/services/system/__init__.py +32 -0
- womm/services/system/detector_service.py +704 -0
- womm/services/system/environment_service.py +494 -0
- womm/services/system/path_service.py +642 -0
- womm/shared/__init__.py +30 -0
- womm/shared/configs/__init__.py +51 -0
- womm/shared/configs/context/__init__.py +43 -0
- womm/shared/configs/context/context_config.py +125 -0
- womm/shared/configs/context/context_file_types_config.py +159 -0
- womm/shared/configs/context/context_limits_config.py +187 -0
- womm/shared/configs/context/context_paths_config.py +115 -0
- womm/shared/configs/context/context_types_config.py +65 -0
- womm/shared/configs/context/script_config.py +219 -0
- womm/shared/configs/dependencies/__init__.py +32 -0
- womm/shared/configs/dependencies/runtime_config.py +46 -0
- womm/shared/configs/dependencies/runtime_package_manager_config.py +48 -0
- womm/shared/configs/logging_config.py +89 -0
- womm/shared/configs/project/__init__.py +33 -0
- womm/shared/configs/project/project_config.py +109 -0
- womm/shared/configs/project/project_structure_config.py +88 -0
- womm/shared/configs/project/python_project_config.py +165 -0
- womm/shared/configs/security/__init__.py +26 -0
- womm/shared/configs/security/security_patterns_config.py +242 -0
- womm/shared/configs/system/__init__.py +28 -0
- womm/shared/configs/system/system_detector_config.py +210 -0
- womm/shared/configs/system/system_environment_config.py +101 -0
- womm/shared/models/__init__.py +13 -0
- womm/shared/models/template_source.py +65 -0
- womm/shared/paths.py +192 -0
- womm/shared/results/__init__.py +138 -0
- womm/shared/results/base.py +85 -0
- womm/shared/results/command_results.py +61 -0
- womm/shared/results/context_results.py +345 -0
- womm/shared/results/dependency_results.py +110 -0
- womm/shared/results/doctor_results.py +41 -0
- womm/shared/results/file_results.py +97 -0
- womm/shared/results/project_results.py +163 -0
- womm/shared/results/security_results.py +128 -0
- womm/shared/results/system_results.py +268 -0
- womm/shared/results/template_results.py +43 -0
- womm/shared/runtime.py +36 -0
- womm/ui/__init__.py +31 -0
- womm/ui/common/__init__.py +39 -0
- womm/ui/common/interactive_menu.py +246 -0
- womm/ui/common/logging.py +184 -0
- womm/ui/common/prompts.py +93 -0
- womm/ui/context/__init__.py +31 -0
- womm/ui/context/display.py +485 -0
- womm/ui/context/menu_display.py +189 -0
- womm/ui/context/wizard.py +557 -0
- womm/ui/project/__init__.py +42 -0
- womm/ui/project/create/create_completion_summaries.py +55 -0
- womm/ui/project/project_wizard.py +174 -0
- womm/ui/project/setup/setup_completion_summaries.py +111 -0
- womm/ui/project/templates/template_store_display.py +128 -0
- womm/ui/system/__init__.py +60 -0
- womm/ui/system/display.py +531 -0
- womm/ui/system/path_display.py +387 -0
- womm/utils/__init__.py +23 -0
- womm/utils/common/__init__.py +49 -0
- womm/utils/common/file_scanner_utils.py +110 -0
- womm/utils/common/path_resolver_utils.py +127 -0
- womm/utils/common/safe_fs_utils.py +135 -0
- womm/utils/context/__init__.py +54 -0
- womm/utils/context/core_utils.py +345 -0
- womm/utils/context/icon_utils.py +259 -0
- womm/utils/project/__init__.py +106 -0
- womm/utils/project/asset_utils.py +154 -0
- womm/utils/project/core_utils.py +391 -0
- womm/utils/project/file_utils.py +494 -0
- womm/utils/project/platform_utils.py +170 -0
- womm/utils/project/validation_utils.py +273 -0
- womm/utils/security/__init__.py +46 -0
- womm/utils/security/security_validation_utils.py +258 -0
- womm/utils/system/__init__.py +69 -0
- womm/utils/system/detector_utils.py +299 -0
- womm/utils/system/environment_utils.py +172 -0
- womm/utils/system/path_utils.py +101 -0
- womm_cli-4.0.0.dist-info/METADATA +203 -0
- womm_cli-4.0.0.dist-info/RECORD +218 -0
- womm_cli-4.0.0.dist-info/WHEEL +4 -0
- womm_cli-4.0.0.dist-info/entry_points.txt +2 -0
- womm_cli-4.0.0.dist-info/licenses/LICENSE +21 -0
womm/ui/__init__.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# UI - User Interface Module
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
User Interface module for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This package contains UI components using Rich for beautiful terminal output.
|
|
11
|
+
Provides console utilities, interactive components, and display functions.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Local imports
|
|
20
|
+
from . import common, context, project, system
|
|
21
|
+
|
|
22
|
+
# ///////////////////////////////////////////////////////////////
|
|
23
|
+
# PUBLIC API
|
|
24
|
+
# ///////////////////////////////////////////////////////////////
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"common",
|
|
28
|
+
"context",
|
|
29
|
+
"project",
|
|
30
|
+
"system",
|
|
31
|
+
]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# UI COMMON - Common UI Components
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Common UI components for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This module re-exports UI utilities, prompts, and interactive_menu.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
# ///////////////////////////////////////////////////////////////
|
|
16
|
+
# IMPORTS
|
|
17
|
+
# ///////////////////////////////////////////////////////////////
|
|
18
|
+
# Local imports
|
|
19
|
+
from .interactive_menu import InteractiveMenu, format_backup_item
|
|
20
|
+
from .logging import WommPrinter, ezconsole, ezlogger, ezpl, ezprinter, ezwizard
|
|
21
|
+
from .prompts import confirm, prompt_choice, prompt_path
|
|
22
|
+
|
|
23
|
+
# ///////////////////////////////////////////////////////////////
|
|
24
|
+
# PUBLIC API
|
|
25
|
+
# ///////////////////////////////////////////////////////////////
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"WommPrinter",
|
|
29
|
+
"InteractiveMenu",
|
|
30
|
+
"confirm",
|
|
31
|
+
"ezconsole",
|
|
32
|
+
"ezlogger",
|
|
33
|
+
"ezpl",
|
|
34
|
+
"ezprinter",
|
|
35
|
+
"ezwizard",
|
|
36
|
+
"format_backup_item",
|
|
37
|
+
"prompt_choice",
|
|
38
|
+
"prompt_path",
|
|
39
|
+
]
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# INTERACTIVE - Interactive UI Components
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Interactive UI components for Works On My Machine.
|
|
9
|
+
Provides interactive menus and dialogs using InquirerPy.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
# ///////////////////////////////////////////////////////////////
|
|
15
|
+
# IMPORTS
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# Standard library imports
|
|
18
|
+
from collections.abc import Callable
|
|
19
|
+
from datetime import datetime
|
|
20
|
+
from typing import Any, cast
|
|
21
|
+
|
|
22
|
+
# Third-party imports
|
|
23
|
+
from InquirerPy import inquirer # pyright: ignore[reportPrivateImportUsage]
|
|
24
|
+
from InquirerPy.base.control import Choice
|
|
25
|
+
from prompt_toolkit.styles import Style
|
|
26
|
+
|
|
27
|
+
# ///////////////////////////////////////////////////////////////
|
|
28
|
+
# MAIN CLASS
|
|
29
|
+
# ///////////////////////////////////////////////////////////////
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class InteractiveMenu:
|
|
33
|
+
"""Interactive menu with selection using InquirerPy."""
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
title: str = "Menu",
|
|
38
|
+
border_style: str = "cyan",
|
|
39
|
+
pointer: str = "→",
|
|
40
|
+
instruction: str | None = None,
|
|
41
|
+
style: Style | None = None,
|
|
42
|
+
):
|
|
43
|
+
"""Initialize the interactive menu.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
title: Menu title
|
|
47
|
+
border_style: Kept for compatibility (Rich panels)
|
|
48
|
+
pointer: Pointer symbol for selections
|
|
49
|
+
instruction: Optional instruction text displayed under the question
|
|
50
|
+
style: Optional PromptToolkit Style for colors/formatting
|
|
51
|
+
"""
|
|
52
|
+
self.title = title
|
|
53
|
+
self.border_style = border_style
|
|
54
|
+
self.pointer = pointer
|
|
55
|
+
self.instruction = instruction
|
|
56
|
+
self.style = style
|
|
57
|
+
|
|
58
|
+
# ///////////////////////////////////////////////////////////////
|
|
59
|
+
# PUBLIC METHODS
|
|
60
|
+
# ///////////////////////////////////////////////////////////////
|
|
61
|
+
# Main interface methods for interactive menus
|
|
62
|
+
|
|
63
|
+
def select_from_list(
|
|
64
|
+
self,
|
|
65
|
+
items: list[dict[str, Any]],
|
|
66
|
+
display_func: Callable[[dict[str, Any]], str] | None = None,
|
|
67
|
+
_default_index: int = 0,
|
|
68
|
+
_width: int = 80,
|
|
69
|
+
) -> dict[str, Any] | None:
|
|
70
|
+
"""Display an interactive menu and return the selected item.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
items: List of items to display
|
|
74
|
+
display_func: Function to format each item for display
|
|
75
|
+
_default_index: Default selected index (ignored with InquirerPy)
|
|
76
|
+
_width: Menu width (ignored with InquirerPy)
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
Selected item or None if cancelled
|
|
80
|
+
"""
|
|
81
|
+
if not items:
|
|
82
|
+
return None
|
|
83
|
+
|
|
84
|
+
# Format choices for display
|
|
85
|
+
choices = []
|
|
86
|
+
for item in items:
|
|
87
|
+
display_text = display_func(item) if display_func else str(item)
|
|
88
|
+
choices.append(display_text)
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
# Use InquirerPy for selection
|
|
92
|
+
choices_objects: list[Choice] = [
|
|
93
|
+
Choice(value=choice, name=choice) for choice in choices
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
if self.instruction is None:
|
|
97
|
+
selected_text = inquirer.select(
|
|
98
|
+
message=self.title,
|
|
99
|
+
choices=choices_objects,
|
|
100
|
+
pointer=self.pointer,
|
|
101
|
+
style=cast(Any, self.style),
|
|
102
|
+
).execute() # pyright: ignore[reportPrivateImportUsage]
|
|
103
|
+
else:
|
|
104
|
+
selected_text = inquirer.select(
|
|
105
|
+
message=self.title,
|
|
106
|
+
choices=choices_objects,
|
|
107
|
+
pointer=self.pointer,
|
|
108
|
+
instruction=self.instruction,
|
|
109
|
+
style=cast(Any, self.style),
|
|
110
|
+
).execute() # pyright: ignore[reportPrivateImportUsage]
|
|
111
|
+
|
|
112
|
+
if selected_text is None:
|
|
113
|
+
return None
|
|
114
|
+
|
|
115
|
+
# Find the corresponding item
|
|
116
|
+
for i, choice in enumerate(choices):
|
|
117
|
+
if choice == selected_text:
|
|
118
|
+
return items[i]
|
|
119
|
+
|
|
120
|
+
return None
|
|
121
|
+
|
|
122
|
+
except KeyboardInterrupt:
|
|
123
|
+
return None
|
|
124
|
+
|
|
125
|
+
def select_multiple_from_list(
|
|
126
|
+
self,
|
|
127
|
+
items: list[dict[str, Any]],
|
|
128
|
+
display_func: Callable[[dict[str, Any]], str] | None = None,
|
|
129
|
+
_checked_items: list[str] | None = None,
|
|
130
|
+
disabled_items: list[str] | None = None,
|
|
131
|
+
) -> list[dict[str, Any]] | None:
|
|
132
|
+
"""Display an interactive multiple selection menu and return selected items.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
items: List of items to display
|
|
136
|
+
display_func: Function to format each item for display
|
|
137
|
+
_checked_items: (unused) kept for API parity
|
|
138
|
+
disabled_items: List of item keys that should be considered installed
|
|
139
|
+
and therefore hidden from selection
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
List of selected items or None if cancelled
|
|
143
|
+
"""
|
|
144
|
+
if not items:
|
|
145
|
+
return []
|
|
146
|
+
|
|
147
|
+
# Format choices for InquirerPy with checkbox logic
|
|
148
|
+
choices = []
|
|
149
|
+
for item in items:
|
|
150
|
+
display_text = display_func(item) if display_func else str(item)
|
|
151
|
+
|
|
152
|
+
# Determine if item should be hidden (already installed)
|
|
153
|
+
item_key = item.get("key", str(item))
|
|
154
|
+
is_disabled = disabled_items and item_key in disabled_items
|
|
155
|
+
|
|
156
|
+
# Skip already installed items (don't show them in the selection)
|
|
157
|
+
if is_disabled:
|
|
158
|
+
continue
|
|
159
|
+
|
|
160
|
+
# Create InquirerPy Choice only for non-installed items
|
|
161
|
+
choice = Choice(value=item, name=display_text)
|
|
162
|
+
choices.append(choice)
|
|
163
|
+
|
|
164
|
+
try:
|
|
165
|
+
# Use InquirerPy for multiple selection
|
|
166
|
+
if self.instruction is None:
|
|
167
|
+
selected_items = inquirer.checkbox(
|
|
168
|
+
message=self.title,
|
|
169
|
+
choices=choices,
|
|
170
|
+
pointer=self.pointer,
|
|
171
|
+
style=cast(Any, self.style),
|
|
172
|
+
).execute() # pyright: ignore[reportPrivateImportUsage]
|
|
173
|
+
else:
|
|
174
|
+
selected_items = inquirer.checkbox(
|
|
175
|
+
message=self.title,
|
|
176
|
+
choices=choices,
|
|
177
|
+
pointer=self.pointer,
|
|
178
|
+
instruction=self.instruction,
|
|
179
|
+
style=cast(Any, self.style),
|
|
180
|
+
).execute() # pyright: ignore[reportPrivateImportUsage]
|
|
181
|
+
|
|
182
|
+
if selected_items is None:
|
|
183
|
+
return None
|
|
184
|
+
|
|
185
|
+
return selected_items
|
|
186
|
+
|
|
187
|
+
except KeyboardInterrupt:
|
|
188
|
+
return None
|
|
189
|
+
|
|
190
|
+
def confirm_action(
|
|
191
|
+
self, message: str = "Confirm action", default_yes: bool = True
|
|
192
|
+
) -> bool:
|
|
193
|
+
"""Display a confirmation dialog.
|
|
194
|
+
|
|
195
|
+
Args:
|
|
196
|
+
message: Confirmation message
|
|
197
|
+
default_yes: Whether "Yes" should be the default selection
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
True if confirmed, False if cancelled or denied
|
|
201
|
+
"""
|
|
202
|
+
try:
|
|
203
|
+
# Use InquirerPy for confirmation
|
|
204
|
+
result = inquirer.confirm(
|
|
205
|
+
message=message,
|
|
206
|
+
default=default_yes,
|
|
207
|
+
style=cast(Any, self.style),
|
|
208
|
+
).execute() # pyright: ignore[reportPrivateImportUsage]
|
|
209
|
+
|
|
210
|
+
return result if result is not None else False
|
|
211
|
+
|
|
212
|
+
except KeyboardInterrupt:
|
|
213
|
+
return False
|
|
214
|
+
|
|
215
|
+
# ///////////////////////////////////////////////////////////////
|
|
216
|
+
# PRIVATE METHODS
|
|
217
|
+
# ///////////////////////////////////////////////////////////////
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# ///////////////////////////////////////////////////////////////
|
|
221
|
+
# UTILITY FUNCTIONS
|
|
222
|
+
# ///////////////////////////////////////////////////////////////
|
|
223
|
+
# Helper functions for formatting and display
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def format_backup_item(backup_info: dict[str, Any]) -> str:
|
|
227
|
+
"""Format a backup item for display in the menu.
|
|
228
|
+
|
|
229
|
+
Args:
|
|
230
|
+
backup_info: Backup information dictionary
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
Formatted string for display
|
|
234
|
+
"""
|
|
235
|
+
file_info = f"{backup_info['file'].name} ({backup_info['path_entries']} entries)"
|
|
236
|
+
date_info = datetime.fromtimestamp(backup_info["file"].stat().st_mtime).strftime(
|
|
237
|
+
"%Y-%m-%d %H:%M"
|
|
238
|
+
)
|
|
239
|
+
return f"{file_info} - {date_info}"
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
# ///////////////////////////////////////////////////////////////
|
|
243
|
+
# PUBLIC API
|
|
244
|
+
# ///////////////////////////////////////////////////////////////
|
|
245
|
+
|
|
246
|
+
__all__ = ["InteractiveMenu", "format_backup_item"]
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# LOGGING - ezplog integration and WOMM Rich helpers
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
ezplog integration for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This module configures ezplog and extends its printer with the Rich object
|
|
11
|
+
builders that are specific to WOMM.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Standard library imports
|
|
20
|
+
from typing import Any, cast
|
|
21
|
+
|
|
22
|
+
# Third-party imports
|
|
23
|
+
from ezplog import EzLogger, Ezpl, EzPrinter, RichWizard
|
|
24
|
+
from rich.align import Align
|
|
25
|
+
from rich.console import Console
|
|
26
|
+
from rich.panel import Panel
|
|
27
|
+
from rich.table import Table
|
|
28
|
+
from rich.text import Text
|
|
29
|
+
|
|
30
|
+
# Local imports
|
|
31
|
+
from ...shared.configs.logging_config import LoggingConfig
|
|
32
|
+
|
|
33
|
+
# ///////////////////////////////////////////////////////////////
|
|
34
|
+
# EXTENDED PRINTER CLASS
|
|
35
|
+
# ///////////////////////////////////////////////////////////////
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class WommPrinter(EzPrinter):
|
|
39
|
+
"""EzPrinter extended with WOMM-specific Rich object builders."""
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def console(self) -> Console:
|
|
43
|
+
"""Expose the Rich console until ezplog provides a public accessor."""
|
|
44
|
+
return self._console
|
|
45
|
+
|
|
46
|
+
def print_header(self, title: str, **kwargs: Any) -> None:
|
|
47
|
+
"""Display a WOMM command header with separators."""
|
|
48
|
+
self._console.print(":" * 80, style="dim black", **kwargs)
|
|
49
|
+
self._console.print(
|
|
50
|
+
f"** {title} **",
|
|
51
|
+
style="bold black",
|
|
52
|
+
justify="center",
|
|
53
|
+
width=80,
|
|
54
|
+
**kwargs,
|
|
55
|
+
)
|
|
56
|
+
self._console.print(":" * 80, style="dim black", **kwargs)
|
|
57
|
+
self._console.print("")
|
|
58
|
+
|
|
59
|
+
def create_panel(
|
|
60
|
+
self,
|
|
61
|
+
content: Any,
|
|
62
|
+
title: str | None = None,
|
|
63
|
+
border_style: str = "blue",
|
|
64
|
+
width: int = 80,
|
|
65
|
+
**kwargs: Any,
|
|
66
|
+
) -> Panel:
|
|
67
|
+
"""Build a generic WOMM panel without displaying it."""
|
|
68
|
+
return Panel(
|
|
69
|
+
content,
|
|
70
|
+
title=title,
|
|
71
|
+
border_style=border_style,
|
|
72
|
+
width=width,
|
|
73
|
+
**kwargs,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def create_info_panel(
|
|
77
|
+
self,
|
|
78
|
+
title: str,
|
|
79
|
+
content: str,
|
|
80
|
+
style: str = "cyan",
|
|
81
|
+
border_style: str = "cyan",
|
|
82
|
+
width: int = 80,
|
|
83
|
+
**kwargs: Any,
|
|
84
|
+
) -> Panel:
|
|
85
|
+
"""Build a WOMM information panel without displaying it."""
|
|
86
|
+
text = Text(content, style=style)
|
|
87
|
+
return Panel(
|
|
88
|
+
Align(text, align="left"),
|
|
89
|
+
title=f"ℹ️ {title}",
|
|
90
|
+
border_style=border_style,
|
|
91
|
+
width=width,
|
|
92
|
+
**kwargs,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
def create_table(
|
|
96
|
+
self,
|
|
97
|
+
title: str,
|
|
98
|
+
columns: list[str] | list[tuple[str, str | None, bool]],
|
|
99
|
+
rows: list[list[Any]] | None = None,
|
|
100
|
+
show_header: bool = True,
|
|
101
|
+
**kwargs: Any,
|
|
102
|
+
) -> Table:
|
|
103
|
+
"""Build a WOMM table without displaying it."""
|
|
104
|
+
table = Table(title=title, show_header=show_header, **kwargs)
|
|
105
|
+
|
|
106
|
+
for column in columns:
|
|
107
|
+
if isinstance(column, tuple):
|
|
108
|
+
name, style, no_wrap = column
|
|
109
|
+
table.add_column(name, style=style or "cyan", no_wrap=no_wrap)
|
|
110
|
+
else:
|
|
111
|
+
table.add_column(column, style="cyan", no_wrap=True)
|
|
112
|
+
|
|
113
|
+
if rows:
|
|
114
|
+
for row in rows:
|
|
115
|
+
table.add_row(*[str(cell) for cell in row])
|
|
116
|
+
|
|
117
|
+
return table
|
|
118
|
+
|
|
119
|
+
def create_backup_table(self, backups: list[dict[str, Any]]) -> Table:
|
|
120
|
+
"""Build the table used to display PATH backup metadata."""
|
|
121
|
+
table = Table(title="PATH Backups", show_header=True)
|
|
122
|
+
table.add_column("Backup File", style="cyan", no_wrap=True)
|
|
123
|
+
table.add_column("Size", style="green", no_wrap=True)
|
|
124
|
+
table.add_column("Modified", style="yellow", no_wrap=True)
|
|
125
|
+
table.add_column("Description", style="white")
|
|
126
|
+
|
|
127
|
+
for backup in backups:
|
|
128
|
+
size = backup.get("size", 0)
|
|
129
|
+
if size < 1024:
|
|
130
|
+
size_str = f"{size} B"
|
|
131
|
+
elif size < 1024 * 1024:
|
|
132
|
+
size_str = f"{size // 1024} KB"
|
|
133
|
+
else:
|
|
134
|
+
size_str = f"{size // (1024 * 1024)} MB"
|
|
135
|
+
|
|
136
|
+
description = backup.get("description", "No description")
|
|
137
|
+
if len(description) > 50:
|
|
138
|
+
description = description[:47] + "..."
|
|
139
|
+
|
|
140
|
+
table.add_row(
|
|
141
|
+
backup.get("name", ""),
|
|
142
|
+
size_str,
|
|
143
|
+
backup.get("modified", ""),
|
|
144
|
+
description,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
return table
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# ///////////////////////////////////////////////////////////////
|
|
151
|
+
# GLOBAL INSTANCE
|
|
152
|
+
# ///////////////////////////////////////////////////////////////
|
|
153
|
+
|
|
154
|
+
log_folder = LoggingConfig.get_log_dir()
|
|
155
|
+
log_folder.mkdir(parents=True, exist_ok=True)
|
|
156
|
+
first_init = not Ezpl.is_initialized()
|
|
157
|
+
ezpl = Ezpl(
|
|
158
|
+
log_file=LoggingConfig.get_log_file(),
|
|
159
|
+
log_level=LoggingConfig.DEFAULT_LEVEL,
|
|
160
|
+
log_rotation=LoggingConfig.ROTATION,
|
|
161
|
+
log_retention=LoggingConfig.RETENTION,
|
|
162
|
+
log_compression=LoggingConfig.COMPRESSION,
|
|
163
|
+
)
|
|
164
|
+
if first_init:
|
|
165
|
+
ezpl.set_printer_class(WommPrinter)
|
|
166
|
+
ezpl.lock_config()
|
|
167
|
+
|
|
168
|
+
ezprinter = cast(WommPrinter, ezpl.get_printer())
|
|
169
|
+
ezlogger: EzLogger = ezpl.get_logger()
|
|
170
|
+
ezconsole: Console = ezprinter.console
|
|
171
|
+
ezwizard = RichWizard(ezconsole)
|
|
172
|
+
|
|
173
|
+
# ///////////////////////////////////////////////////////////////
|
|
174
|
+
# PUBLIC API
|
|
175
|
+
# ///////////////////////////////////////////////////////////////
|
|
176
|
+
|
|
177
|
+
__all__ = [
|
|
178
|
+
"WommPrinter",
|
|
179
|
+
"ezconsole",
|
|
180
|
+
"ezlogger",
|
|
181
|
+
"ezpl",
|
|
182
|
+
"ezprinter",
|
|
183
|
+
"ezwizard",
|
|
184
|
+
]
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# PROMPTS - Interactive Prompt Components
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Interactive prompt components for user input.
|
|
9
|
+
|
|
10
|
+
This module provides convenient wrappers for common prompt scenarios,
|
|
11
|
+
including confirmations, path input, and choice selection.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Third-party imports
|
|
20
|
+
from InquirerPy import inquirer # pyright: ignore[reportPrivateImportUsage]
|
|
21
|
+
from InquirerPy.base.control import Choice
|
|
22
|
+
from rich.prompt import Confirm, Prompt
|
|
23
|
+
|
|
24
|
+
# ///////////////////////////////////////////////////////////////
|
|
25
|
+
# PUBLIC API
|
|
26
|
+
# ///////////////////////////////////////////////////////////////
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def confirm(prompt_text: str, **kwargs) -> bool:
|
|
30
|
+
"""
|
|
31
|
+
Show a confirmation prompt.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
prompt_text: The confirmation message to display
|
|
35
|
+
**kwargs: Additional arguments passed to Confirm.ask()
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
bool: True if user confirms, False otherwise
|
|
39
|
+
"""
|
|
40
|
+
return Confirm.ask(prompt_text, **kwargs)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def prompt_path(message: str = "Enter path", **kwargs) -> str:
|
|
44
|
+
"""
|
|
45
|
+
Prompt for a file path.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
message: The prompt message to display
|
|
49
|
+
**kwargs: Additional arguments passed to Prompt.ask()
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
str: The entered path as a string
|
|
53
|
+
"""
|
|
54
|
+
return Prompt.ask(message, **kwargs)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def prompt_choice(message: str, choices: list[str], **kwargs) -> str:
|
|
58
|
+
"""
|
|
59
|
+
Show a selection prompt with multiple choices.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
message: The prompt message to display
|
|
63
|
+
choices: List of string choices to present to user
|
|
64
|
+
**kwargs: Additional arguments passed to InquirerPy select
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
str: The selected choice string
|
|
68
|
+
|
|
69
|
+
Raises:
|
|
70
|
+
KeyboardInterrupt: If user cancels the prompt
|
|
71
|
+
ValueError: If choices list is empty
|
|
72
|
+
"""
|
|
73
|
+
if not choices:
|
|
74
|
+
raise ValueError("Choices list cannot be empty")
|
|
75
|
+
|
|
76
|
+
choice_objects = [Choice(value=choice, name=choice) for choice in choices]
|
|
77
|
+
result = inquirer.select( # pyright: ignore[reportPrivateImportUsage]
|
|
78
|
+
message=message,
|
|
79
|
+
choices=choice_objects,
|
|
80
|
+
**kwargs,
|
|
81
|
+
).execute()
|
|
82
|
+
|
|
83
|
+
if result is None:
|
|
84
|
+
raise KeyboardInterrupt("Selection cancelled")
|
|
85
|
+
|
|
86
|
+
return result
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# ///////////////////////////////////////////////////////////////
|
|
90
|
+
# PUBLIC API
|
|
91
|
+
# ///////////////////////////////////////////////////////////////
|
|
92
|
+
|
|
93
|
+
__all__ = ["confirm", "prompt_choice", "prompt_path"]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# UI CONTEXT - Context Menu UI Components
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Context Menu UI components for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This module provides UI components for context menu operations,
|
|
11
|
+
including wizards and menu displays.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Local imports
|
|
20
|
+
from .menu_display import ContextMenuUI, format_entry_display
|
|
21
|
+
from .wizard import ContextMenuWizard
|
|
22
|
+
|
|
23
|
+
# ///////////////////////////////////////////////////////////////
|
|
24
|
+
# PUBLIC API
|
|
25
|
+
# ///////////////////////////////////////////////////////////////
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"ContextMenuUI",
|
|
29
|
+
"ContextMenuWizard",
|
|
30
|
+
"format_entry_display",
|
|
31
|
+
]
|