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
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# CONTEXT DISPLAY - Context Result Display Functions
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Context result display functions.
|
|
9
|
+
|
|
10
|
+
Provides display functions for context menu operation results.
|
|
11
|
+
These functions render Result objects to the console using rich.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Standard library imports
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
# Third-party imports
|
|
23
|
+
from rich.panel import Panel
|
|
24
|
+
|
|
25
|
+
# Local imports
|
|
26
|
+
from ...shared.results import (
|
|
27
|
+
BackupDataResult,
|
|
28
|
+
BackupFileListResult,
|
|
29
|
+
ContextBackupResult,
|
|
30
|
+
ContextCherryPickResult,
|
|
31
|
+
ContextEntriesResult,
|
|
32
|
+
ContextRestoreResult,
|
|
33
|
+
ContextSetupResult,
|
|
34
|
+
ScriptRegistrationResult,
|
|
35
|
+
ScriptUnregistrationResult,
|
|
36
|
+
)
|
|
37
|
+
from ..common.logging import ezconsole, ezprinter
|
|
38
|
+
|
|
39
|
+
# ///////////////////////////////////////////////////////////////
|
|
40
|
+
# SCRIPT REGISTRATION DISPLAY FUNCTIONS
|
|
41
|
+
# ///////////////////////////////////////////////////////////////
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def render_script_registration_result(result: ScriptRegistrationResult) -> None:
|
|
45
|
+
"""Render a script registration result.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
result: The ScriptRegistrationResult to render
|
|
49
|
+
"""
|
|
50
|
+
if result.success:
|
|
51
|
+
if result.dry_run:
|
|
52
|
+
ezprinter.info("Dry run - no changes made")
|
|
53
|
+
ezprinter.info(f"Would register: {result.label}")
|
|
54
|
+
else:
|
|
55
|
+
ezprinter.success(
|
|
56
|
+
f"Tool '{result.label}' registered successfully in context menu"
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
tip_content = """Right-click in any folder to see your new context menu entry.
|
|
60
|
+
|
|
61
|
+
- The entry will appear in both folder and background context menus
|
|
62
|
+
- Use womm context list to see all registered entries
|
|
63
|
+
- Use womm context unregister --remove <key> to remove entries later"""
|
|
64
|
+
|
|
65
|
+
tip_panel = Panel(
|
|
66
|
+
tip_content,
|
|
67
|
+
title="Context Menu Usage",
|
|
68
|
+
border_style="green",
|
|
69
|
+
style="bright_green",
|
|
70
|
+
padding=(1, 1),
|
|
71
|
+
width=80,
|
|
72
|
+
)
|
|
73
|
+
ezconsole.print("")
|
|
74
|
+
ezconsole.print(tip_panel)
|
|
75
|
+
ezconsole.print("")
|
|
76
|
+
else:
|
|
77
|
+
ezprinter.error(f"Registration failed: {result.error}")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# ///////////////////////////////////////////////////////////////
|
|
81
|
+
# SCRIPT UNREGISTRATION DISPLAY FUNCTIONS
|
|
82
|
+
# ///////////////////////////////////////////////////////////////
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def render_script_unregistration_result(result: ScriptUnregistrationResult) -> None:
|
|
86
|
+
"""Render a script unregistration result.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
result: The ScriptUnregistrationResult to render
|
|
90
|
+
"""
|
|
91
|
+
if result.success:
|
|
92
|
+
ezprinter.success(
|
|
93
|
+
f"Entry '{result.key_name}' removed successfully from context menu"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
tip_content = """Context menu entry has been removed successfully.
|
|
97
|
+
|
|
98
|
+
- Changes will be visible after refreshing File Explorer
|
|
99
|
+
- Use womm context list to verify the removal
|
|
100
|
+
- Use womm context register to add new entries"""
|
|
101
|
+
|
|
102
|
+
tip_panel = Panel(
|
|
103
|
+
tip_content,
|
|
104
|
+
title="Unregistration Complete",
|
|
105
|
+
border_style="green",
|
|
106
|
+
style="bright_green",
|
|
107
|
+
padding=(1, 1),
|
|
108
|
+
width=80,
|
|
109
|
+
)
|
|
110
|
+
ezconsole.print("")
|
|
111
|
+
ezconsole.print(tip_panel)
|
|
112
|
+
ezconsole.print("")
|
|
113
|
+
|
|
114
|
+
if result.permission_errors:
|
|
115
|
+
for error in result.permission_errors:
|
|
116
|
+
ezprinter.warning(f"Permission error: {error}")
|
|
117
|
+
else:
|
|
118
|
+
ezprinter.error(f"Unregistration failed: {result.error}")
|
|
119
|
+
if result.permission_errors:
|
|
120
|
+
for error in result.permission_errors:
|
|
121
|
+
ezprinter.error(f" Permission error: {error}")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# ///////////////////////////////////////////////////////////////
|
|
125
|
+
# BACKUP DISPLAY FUNCTIONS
|
|
126
|
+
# ///////////////////////////////////////////////////////////////
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def render_context_backup_result(result: ContextBackupResult) -> None:
|
|
130
|
+
"""Render a context backup result.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
result: The ContextBackupResult to render
|
|
134
|
+
"""
|
|
135
|
+
if result.success:
|
|
136
|
+
ezprinter.success("Backup completed successfully!")
|
|
137
|
+
if result.backup_file:
|
|
138
|
+
ezprinter.info(f"Backup saved to: {result.backup_file}")
|
|
139
|
+
ezprinter.info(f"{result.entry_count} entries backed up")
|
|
140
|
+
|
|
141
|
+
tip_content = f"""Context menu backup completed successfully.
|
|
142
|
+
|
|
143
|
+
- Backup file: {result.backup_file or "default location"}
|
|
144
|
+
- {result.entry_count} entries backed up
|
|
145
|
+
- Use this backup to restore context menu entries if needed
|
|
146
|
+
- You can specify a custom backup location with --output"""
|
|
147
|
+
|
|
148
|
+
tip_panel = Panel(
|
|
149
|
+
tip_content,
|
|
150
|
+
title="Backup Information",
|
|
151
|
+
border_style="yellow",
|
|
152
|
+
style="bright_yellow",
|
|
153
|
+
padding=(1, 1),
|
|
154
|
+
width=80,
|
|
155
|
+
)
|
|
156
|
+
ezconsole.print("")
|
|
157
|
+
ezconsole.print(tip_panel)
|
|
158
|
+
ezconsole.print("")
|
|
159
|
+
else:
|
|
160
|
+
ezprinter.error(f"Backup failed: {result.error}")
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# //://:obe/////////////////////////////
|
|
164
|
+
# RESTORE DISPLAY FUNCTIONS
|
|
165
|
+
# ///////////////////////////////////////////////////////////////
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def render_context_restore_result(result: ContextRestoreResult) -> None:
|
|
169
|
+
"""Render a context restore result.
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
result: The ContextRestoreResult to render
|
|
173
|
+
"""
|
|
174
|
+
if result.success:
|
|
175
|
+
ezprinter.success("Context menu restored successfully!")
|
|
176
|
+
if result.backup_file:
|
|
177
|
+
ezprinter.info(f"Restored from: {result.backup_file}")
|
|
178
|
+
|
|
179
|
+
tip_content = f"""Context menu restore completed successfully.
|
|
180
|
+
|
|
181
|
+
- Restored from: {result.backup_file or "default backup"}
|
|
182
|
+
- {result.entry_count} entries restored
|
|
183
|
+
- Changes should be visible immediately in File Explorer
|
|
184
|
+
- Use womm context list to verify the restored entries"""
|
|
185
|
+
|
|
186
|
+
tip_panel = Panel(
|
|
187
|
+
tip_content,
|
|
188
|
+
title="Restore Complete",
|
|
189
|
+
border_style="green",
|
|
190
|
+
style="bright_green",
|
|
191
|
+
padding=(1, 1),
|
|
192
|
+
width=80,
|
|
193
|
+
)
|
|
194
|
+
ezconsole.print("")
|
|
195
|
+
ezconsole.print(tip_panel)
|
|
196
|
+
ezconsole.print("")
|
|
197
|
+
else:
|
|
198
|
+
ezprinter.error(f"Restore failed: {result.error}")
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
# //://:obe/////////////////////////////
|
|
202
|
+
# ENTRIES DISPLAY FUNCTIONS
|
|
203
|
+
# ///////////////////////////////////////////////////////////////
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def render_context_entries_result(result: ContextEntriesResult) -> None:
|
|
207
|
+
"""Render a context entries result, summary first.
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
result: The ContextEntriesResult to render
|
|
211
|
+
"""
|
|
212
|
+
if not result.success:
|
|
213
|
+
ezprinter.error(f"Failed to retrieve context menu entries: {result.error}")
|
|
214
|
+
return
|
|
215
|
+
|
|
216
|
+
ezprinter.print_header("Context Menu Entries")
|
|
217
|
+
|
|
218
|
+
ezconsole.print(f"[bold]Total: {result.total_entries}[/bold]")
|
|
219
|
+
for context_type, count in result.entries_by_type.items():
|
|
220
|
+
ezconsole.print(f" {context_type}: {count}")
|
|
221
|
+
|
|
222
|
+
entries = result.entries or {}
|
|
223
|
+
for context_type in entries:
|
|
224
|
+
ezconsole.print(f"\n[bold]{context_type.upper()} CONTEXT:[/bold]")
|
|
225
|
+
context_entries = entries[context_type]
|
|
226
|
+
|
|
227
|
+
if not context_entries:
|
|
228
|
+
ezconsole.print(" No entries found")
|
|
229
|
+
continue
|
|
230
|
+
|
|
231
|
+
for entry in context_entries:
|
|
232
|
+
ezconsole.print(f" Key: {entry.get('key_name', 'Unknown')}")
|
|
233
|
+
display_name = entry.get("display_name", entry.get("key_name", "Unknown"))
|
|
234
|
+
ezconsole.print(f" Display: {display_name}")
|
|
235
|
+
if entry.get("command"):
|
|
236
|
+
ezconsole.print(f" Command: {entry['command']}")
|
|
237
|
+
if entry.get("icon"):
|
|
238
|
+
ezconsole.print(f" Icon: {entry['icon']}")
|
|
239
|
+
ezconsole.print("")
|
|
240
|
+
|
|
241
|
+
show_list_commands()
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
# ///////////////////////////////////////////////////////////////
|
|
245
|
+
# BACKUP LISTING AND CONTENT DISPLAY FUNCTIONS
|
|
246
|
+
# ///////////////////////////////////////////////////////////////
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def render_context_backup_list_result(result: BackupFileListResult) -> None:
|
|
250
|
+
"""Render the list of available context menu backup files.
|
|
251
|
+
|
|
252
|
+
Args:
|
|
253
|
+
result: The BackupFileListResult to render
|
|
254
|
+
"""
|
|
255
|
+
if not result.success:
|
|
256
|
+
ezprinter.error(f"Failed to list backups: {result.error}")
|
|
257
|
+
show_tip_panel(
|
|
258
|
+
"""Troubleshooting backup listing:
|
|
259
|
+
|
|
260
|
+
- Check that the backup directory exists and is readable
|
|
261
|
+
- Create a first backup with womm context backup create""",
|
|
262
|
+
"Troubleshooting",
|
|
263
|
+
)
|
|
264
|
+
return
|
|
265
|
+
|
|
266
|
+
backups = result.backups or []
|
|
267
|
+
if not backups:
|
|
268
|
+
ezprinter.info(f"No backups found in {result.backup_directory}")
|
|
269
|
+
getting_started = Panel(
|
|
270
|
+
"""No context menu backup yet.
|
|
271
|
+
|
|
272
|
+
- womm context backup create - Create your first backup
|
|
273
|
+
- womm context list - See what would be backed up""",
|
|
274
|
+
title="Getting Started",
|
|
275
|
+
border_style="blue",
|
|
276
|
+
style="bright_blue",
|
|
277
|
+
padding=(1, 1),
|
|
278
|
+
width=80,
|
|
279
|
+
)
|
|
280
|
+
ezconsole.print("")
|
|
281
|
+
ezconsole.print(getting_started)
|
|
282
|
+
ezconsole.print("")
|
|
283
|
+
return
|
|
284
|
+
|
|
285
|
+
ezprinter.success(f"Found {len(backups)} backup(s) in {result.backup_directory}")
|
|
286
|
+
for backup in backups:
|
|
287
|
+
modified = (
|
|
288
|
+
backup.modified_time.strftime("%Y-%m-%d %H:%M:%S")
|
|
289
|
+
if backup.modified_time
|
|
290
|
+
else "unknown"
|
|
291
|
+
)
|
|
292
|
+
ezconsole.print(f" {backup.filename}")
|
|
293
|
+
ezconsole.print(
|
|
294
|
+
f" {modified} | {backup.size_kb:.1f} KB | {backup.entry_count} entries"
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
commands_panel = Panel(
|
|
298
|
+
"""Backup commands:
|
|
299
|
+
|
|
300
|
+
- womm context backup show <name> - Inspect a backup's content
|
|
301
|
+
- womm context backup restore <name> - Restore a backup
|
|
302
|
+
- womm context backup cherry-pick - Pick individual entries""",
|
|
303
|
+
title="Backup Commands",
|
|
304
|
+
border_style="blue",
|
|
305
|
+
style="bright_blue",
|
|
306
|
+
padding=(1, 1),
|
|
307
|
+
width=80,
|
|
308
|
+
)
|
|
309
|
+
ezconsole.print("")
|
|
310
|
+
ezconsole.print(commands_panel)
|
|
311
|
+
ezconsole.print("")
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def render_context_backup_content_result(result: BackupDataResult) -> None:
|
|
315
|
+
"""Render the content of a single context menu backup file.
|
|
316
|
+
|
|
317
|
+
Args:
|
|
318
|
+
result: The BackupDataResult to render
|
|
319
|
+
"""
|
|
320
|
+
if not result.success:
|
|
321
|
+
ezprinter.error(f"Could not read backup: {result.error}")
|
|
322
|
+
show_tip_panel(
|
|
323
|
+
"""Troubleshooting backup reading:
|
|
324
|
+
|
|
325
|
+
- Backups are named, not path-addressed: pass a bare file name
|
|
326
|
+
- Run womm context backup list to see the available names""",
|
|
327
|
+
"Troubleshooting",
|
|
328
|
+
)
|
|
329
|
+
return
|
|
330
|
+
|
|
331
|
+
metadata = result.metadata or {}
|
|
332
|
+
ezprinter.success(f"Backup: {Path(result.filepath).name}")
|
|
333
|
+
ezconsole.print(f" Created: {metadata.get('timestamp', 'unknown')}")
|
|
334
|
+
ezconsole.print(f" Version: {metadata.get('version', 'unknown')}")
|
|
335
|
+
ezconsole.print(f" Entries: {metadata.get('total_entries', 0)}")
|
|
336
|
+
|
|
337
|
+
for context_type, stats in (result.entry_stats or {}).items():
|
|
338
|
+
ezconsole.print(f"\n[bold]{context_type.upper()} CONTEXT:[/bold]")
|
|
339
|
+
ezconsole.print(f" Count: {stats.get('count', 0)}")
|
|
340
|
+
for key in stats.get("sample_keys", []):
|
|
341
|
+
ezconsole.print(f" - {key}")
|
|
342
|
+
|
|
343
|
+
restore_panel = Panel(
|
|
344
|
+
f"""To restore this backup:
|
|
345
|
+
|
|
346
|
+
- womm context backup restore {Path(result.filepath).name}
|
|
347
|
+
- womm context backup cherry-pick - Pick individual entries instead""",
|
|
348
|
+
title="Backup Content",
|
|
349
|
+
border_style="blue",
|
|
350
|
+
style="bright_blue",
|
|
351
|
+
padding=(1, 1),
|
|
352
|
+
width=80,
|
|
353
|
+
)
|
|
354
|
+
ezconsole.print("")
|
|
355
|
+
ezconsole.print(restore_panel)
|
|
356
|
+
ezconsole.print("")
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
# //://:obe
|
|
360
|
+
# SETUP DISPLAY FUNCTIONS
|
|
361
|
+
# ///////////////////////////////////////////////////////////////
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def render_context_setup_result(result: ContextSetupResult) -> None:
|
|
365
|
+
"""Render a context setup result.
|
|
366
|
+
|
|
367
|
+
Args:
|
|
368
|
+
result: The ContextSetupResult to render
|
|
369
|
+
"""
|
|
370
|
+
if result.success:
|
|
371
|
+
ezprinter.success(
|
|
372
|
+
f"All {result.total_tools} WOMM tools registered successfully!"
|
|
373
|
+
)
|
|
374
|
+
ezprinter.info("Right-click in any folder to access WOMM tools")
|
|
375
|
+
else:
|
|
376
|
+
ezprinter.info(
|
|
377
|
+
f"Registered {result.success_count}/{result.total_tools} tools successfully"
|
|
378
|
+
)
|
|
379
|
+
if result.error:
|
|
380
|
+
ezprinter.error(f"Setup error: {result.error}")
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
# //://:obe
|
|
384
|
+
# CHERRY-PICK DISPLAY FUNCTIONS
|
|
385
|
+
# ///////////////////////////////////////////////////////////////
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def render_context_cherry_pick_result(result: ContextCherryPickResult) -> None:
|
|
389
|
+
"""Render a cherry-pick result.
|
|
390
|
+
|
|
391
|
+
Args:
|
|
392
|
+
result: The ContextCherryPickResult to render
|
|
393
|
+
"""
|
|
394
|
+
if result.success:
|
|
395
|
+
ezprinter.success(
|
|
396
|
+
f"Cherry-pick completed! {result.success_count} entries installed"
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
tip_content = f"""Cherry-pick installation completed successfully.
|
|
400
|
+
|
|
401
|
+
- {result.success_count} context menu entries installed
|
|
402
|
+
- Changes should be visible immediately in File Explorer
|
|
403
|
+
- Use womm context list to verify the new entries
|
|
404
|
+
- If an entry does not work, check the original script path"""
|
|
405
|
+
|
|
406
|
+
tip_panel = Panel(
|
|
407
|
+
tip_content,
|
|
408
|
+
title="Cherry-pick Complete",
|
|
409
|
+
border_style="green",
|
|
410
|
+
style="bright_green",
|
|
411
|
+
padding=(1, 1),
|
|
412
|
+
width=80,
|
|
413
|
+
)
|
|
414
|
+
ezconsole.print("")
|
|
415
|
+
ezconsole.print(tip_panel)
|
|
416
|
+
ezconsole.print("")
|
|
417
|
+
else:
|
|
418
|
+
ezprinter.error(f"Cherry-pick failed: {result.error}")
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
# //://:obe
|
|
422
|
+
# HELPER DISPLAY FUNCTIONS
|
|
423
|
+
# ///////////////////////////////////////////////////////////////
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def show_list_commands() -> None:
|
|
427
|
+
"""Show helpful commands panel after listing entries."""
|
|
428
|
+
tip_content = """Context menu management commands:
|
|
429
|
+
|
|
430
|
+
- womm context register --target <file> --label "<name>" - Add new entry
|
|
431
|
+
- womm context unregister --remove <key> - Remove existing entry
|
|
432
|
+
- womm context backup create - Create backup of current entries
|
|
433
|
+
- womm context backup list - List available backups
|
|
434
|
+
- womm context backup restore <name> - Restore entries from backup"""
|
|
435
|
+
|
|
436
|
+
tip_panel = Panel(
|
|
437
|
+
tip_content,
|
|
438
|
+
title="Context Menu Commands",
|
|
439
|
+
border_style="blue",
|
|
440
|
+
style="bright_blue",
|
|
441
|
+
padding=(1, 1),
|
|
442
|
+
width=80,
|
|
443
|
+
)
|
|
444
|
+
ezconsole.print("")
|
|
445
|
+
ezconsole.print(tip_panel)
|
|
446
|
+
ezconsole.print("")
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def show_tip_panel(content: str, title: str = "Tip") -> None:
|
|
450
|
+
"""Show a tip panel with consistent formatting.
|
|
451
|
+
|
|
452
|
+
Args:
|
|
453
|
+
content: The content to display in the panel
|
|
454
|
+
title: The title of the panel
|
|
455
|
+
"""
|
|
456
|
+
tip_panel = Panel(
|
|
457
|
+
content,
|
|
458
|
+
title=title,
|
|
459
|
+
border_style="yellow",
|
|
460
|
+
style="bright_yellow",
|
|
461
|
+
padding=(1, 1),
|
|
462
|
+
width=80,
|
|
463
|
+
)
|
|
464
|
+
ezconsole.print("")
|
|
465
|
+
ezconsole.print(tip_panel)
|
|
466
|
+
ezconsole.print("")
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
# ///////////////////////////////////////////////////////////////
|
|
470
|
+
# PUBLIC API
|
|
471
|
+
# ///////////////////////////////////////////////////////////////
|
|
472
|
+
|
|
473
|
+
__all__ = [
|
|
474
|
+
"render_context_backup_content_result",
|
|
475
|
+
"render_context_backup_list_result",
|
|
476
|
+
"render_context_backup_result",
|
|
477
|
+
"render_context_cherry_pick_result",
|
|
478
|
+
"render_context_entries_result",
|
|
479
|
+
"render_context_restore_result",
|
|
480
|
+
"render_context_setup_result",
|
|
481
|
+
"render_script_registration_result",
|
|
482
|
+
"render_script_unregistration_result",
|
|
483
|
+
"show_list_commands",
|
|
484
|
+
"show_tip_panel",
|
|
485
|
+
]
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# CONTEXT - Context Menu UI Components
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Context menu UI components.
|
|
9
|
+
|
|
10
|
+
Pure presentation: these components receive backup records that a command
|
|
11
|
+
has already read through the interface layer, and never touch the
|
|
12
|
+
filesystem themselves. The `interfaces` and `ui` layers are siblings and
|
|
13
|
+
must not import each other.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# IMPORTS
|
|
20
|
+
# ///////////////////////////////////////////////////////////////
|
|
21
|
+
# Standard library imports
|
|
22
|
+
import ntpath
|
|
23
|
+
import re
|
|
24
|
+
from typing import TYPE_CHECKING
|
|
25
|
+
|
|
26
|
+
# Third-party imports
|
|
27
|
+
from rich.panel import Panel
|
|
28
|
+
|
|
29
|
+
# Local imports
|
|
30
|
+
from ..common.logging import ezconsole, ezprinter
|
|
31
|
+
from ..common.prompts import confirm, prompt_choice
|
|
32
|
+
|
|
33
|
+
if TYPE_CHECKING:
|
|
34
|
+
from ...shared.results import BackupFileInfo
|
|
35
|
+
|
|
36
|
+
# ///////////////////////////////////////////////////////////////
|
|
37
|
+
# FUNCTIONS
|
|
38
|
+
# ///////////////////////////////////////////////////////////////
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _describe(backup: BackupFileInfo) -> str:
|
|
42
|
+
"""Build the one-line label of a backup, used both in the menu and the panel.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
backup: Backup record as produced by the interface layer.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
Label of the form ``name - 📅 date | 📦 size KB (n entries)``.
|
|
49
|
+
"""
|
|
50
|
+
modified = (
|
|
51
|
+
backup.modified_time.strftime("%Y-%m-%d %H:%M:%S")
|
|
52
|
+
if backup.modified_time
|
|
53
|
+
else "unknown"
|
|
54
|
+
)
|
|
55
|
+
return (
|
|
56
|
+
f"{backup.filename} - 📅 {modified} | "
|
|
57
|
+
f"📦 {backup.size_kb:.1f} KB ({backup.entry_count} entries)"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def format_entry_display(entry: dict) -> str:
|
|
62
|
+
"""
|
|
63
|
+
Format a backup entry for display in a selection menu.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
entry: Backup entry as read from a backup file
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
Label of the form ``MUIVerb (exe) [key: key_name]``.
|
|
70
|
+
"""
|
|
71
|
+
key_name = entry.get("key_name", "Unknown")
|
|
72
|
+
properties = entry.get("properties", {})
|
|
73
|
+
|
|
74
|
+
display_text = properties.get("MUIVerb") or properties.get("@", key_name)
|
|
75
|
+
|
|
76
|
+
command = properties.get("Command", "")
|
|
77
|
+
if command:
|
|
78
|
+
exe_match = re.search(r'"([^"]*\.exe)"', command)
|
|
79
|
+
if exe_match:
|
|
80
|
+
exe_name = ntpath.basename(exe_match.group(1))
|
|
81
|
+
display_text = f"{display_text} ({exe_name})"
|
|
82
|
+
|
|
83
|
+
return f"{display_text} [key: {key_name}]"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# ///////////////////////////////////////////////////////////////
|
|
87
|
+
# CLASSES
|
|
88
|
+
# ///////////////////////////////////////////////////////////////
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class ContextMenuUI:
|
|
92
|
+
"""UI components for context menu operations."""
|
|
93
|
+
|
|
94
|
+
@staticmethod
|
|
95
|
+
def show_backup_selection_menu(
|
|
96
|
+
backups: list[BackupFileInfo],
|
|
97
|
+
) -> BackupFileInfo | None:
|
|
98
|
+
"""
|
|
99
|
+
Show interactive menu for selecting a backup to restore.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
backups: Backups to choose from, newest first, as produced by
|
|
103
|
+
``ContextMenuInterface.list_backups()``.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
Selected backup or None if the list is empty or the user
|
|
107
|
+
cancelled.
|
|
108
|
+
"""
|
|
109
|
+
if not backups:
|
|
110
|
+
ezprinter.error("No context menu backups found")
|
|
111
|
+
return None
|
|
112
|
+
|
|
113
|
+
choices = [_describe(backup) for backup in backups]
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
selected_choice = prompt_choice("Choose a backup to restore:", choices)
|
|
117
|
+
return backups[choices.index(selected_choice)]
|
|
118
|
+
except (KeyboardInterrupt, ValueError):
|
|
119
|
+
ezprinter.info("Restore cancelled")
|
|
120
|
+
return None
|
|
121
|
+
|
|
122
|
+
@staticmethod
|
|
123
|
+
def confirm_restore_operation(backup: BackupFileInfo) -> bool:
|
|
124
|
+
"""
|
|
125
|
+
Ask user to confirm the restore operation.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
backup: Backup about to be restored
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
True if user confirms, False otherwise
|
|
132
|
+
"""
|
|
133
|
+
modified = (
|
|
134
|
+
backup.modified_time.strftime("%Y-%m-%d %H:%M:%S")
|
|
135
|
+
if backup.modified_time
|
|
136
|
+
else "unknown"
|
|
137
|
+
)
|
|
138
|
+
details_panel = Panel(
|
|
139
|
+
f"""Backup Details:
|
|
140
|
+
• File: {backup.filename}
|
|
141
|
+
• Entries: {backup.entry_count}
|
|
142
|
+
• Created: {modified}
|
|
143
|
+
• Size: {backup.size_kb:.1f} KB""",
|
|
144
|
+
title="Backup Information",
|
|
145
|
+
border_style="blue",
|
|
146
|
+
style="bright_blue",
|
|
147
|
+
padding=(1, 1),
|
|
148
|
+
width=60,
|
|
149
|
+
)
|
|
150
|
+
ezconsole.print("")
|
|
151
|
+
ezconsole.print(details_panel)
|
|
152
|
+
ezconsole.print("")
|
|
153
|
+
|
|
154
|
+
return confirm(
|
|
155
|
+
"This will overwrite current context menu entries. Proceed?", default=False
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
@staticmethod
|
|
159
|
+
def show_cherry_pick_menu(available_entries: list[dict]) -> list[dict]:
|
|
160
|
+
"""
|
|
161
|
+
Show interactive menu for selecting entries to install.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
available_entries: List of available entries
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
List of selected entries
|
|
168
|
+
"""
|
|
169
|
+
from ..common import InteractiveMenu
|
|
170
|
+
|
|
171
|
+
ezprinter.info("Select context menu entries to install:")
|
|
172
|
+
|
|
173
|
+
menu = InteractiveMenu(
|
|
174
|
+
title="Cherry-pick Context Menu Entries",
|
|
175
|
+
instruction="Use space to select/deselect, enter to confirm, q to quit",
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
selected = menu.select_multiple_from_list(
|
|
179
|
+
available_entries, display_func=format_entry_display
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
return selected if selected else []
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
# ///////////////////////////////////////////////////////////////
|
|
186
|
+
# PUBLIC API
|
|
187
|
+
# ///////////////////////////////////////////////////////////////
|
|
188
|
+
|
|
189
|
+
__all__ = ["ContextMenuUI", "format_entry_display"]
|