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,290 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# CONTEXT REGISTRATION - Register and unregister commands
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Registration commands for the context menu.
|
|
9
|
+
|
|
10
|
+
Behaviour is unchanged from the single-module version: these commands only
|
|
11
|
+
moved file.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Standard library imports
|
|
20
|
+
import sys
|
|
21
|
+
|
|
22
|
+
# Third-party imports
|
|
23
|
+
import click
|
|
24
|
+
from ezplog import LogLevel
|
|
25
|
+
|
|
26
|
+
# Local imports
|
|
27
|
+
from ....interfaces import ContextMenuInterface
|
|
28
|
+
from ....services.context import ContextParameters
|
|
29
|
+
from ....ui.common import ezpl, ezprinter, ezwizard
|
|
30
|
+
from ....ui.context import ContextMenuWizard
|
|
31
|
+
from ....ui.context.display import (
|
|
32
|
+
render_script_registration_result,
|
|
33
|
+
render_script_unregistration_result,
|
|
34
|
+
)
|
|
35
|
+
from . import _check_windows, context_group
|
|
36
|
+
|
|
37
|
+
# ///////////////////////////////////////////////////////////////
|
|
38
|
+
# FUNCTIONS
|
|
39
|
+
# ///////////////////////////////////////////////////////////////
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _resolve_registration_target(
|
|
43
|
+
target_path: str | None,
|
|
44
|
+
label: str | None,
|
|
45
|
+
icon: str,
|
|
46
|
+
root: bool,
|
|
47
|
+
file: bool,
|
|
48
|
+
files: bool,
|
|
49
|
+
background: bool,
|
|
50
|
+
file_types: tuple[str, ...],
|
|
51
|
+
extensions: tuple[str, ...],
|
|
52
|
+
interactive: bool,
|
|
53
|
+
) -> tuple[str, str, str, ContextParameters] | None:
|
|
54
|
+
"""Resolve the (target, label, icon, context_params) tuple for registration.
|
|
55
|
+
|
|
56
|
+
Runs the interactive wizard or validates the non-interactive flags.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
The resolved tuple, or None if the user cancelled (interactive) or a
|
|
60
|
+
required option is missing (non-interactive).
|
|
61
|
+
"""
|
|
62
|
+
if interactive:
|
|
63
|
+
wizard_target, wizard_label, wizard_icon, context_params = (
|
|
64
|
+
ContextMenuWizard.run_setup()
|
|
65
|
+
)
|
|
66
|
+
if not wizard_target or not wizard_label or context_params is None:
|
|
67
|
+
return None
|
|
68
|
+
resolved_icon = (
|
|
69
|
+
wizard_icon if isinstance(wizard_icon, str) and wizard_icon else "auto"
|
|
70
|
+
)
|
|
71
|
+
return wizard_target, wizard_label, resolved_icon, context_params
|
|
72
|
+
|
|
73
|
+
if not target_path:
|
|
74
|
+
ezprinter.error("Missing required option: --target")
|
|
75
|
+
ezprinter.info("Use --interactive for guided setup")
|
|
76
|
+
return None
|
|
77
|
+
if not label:
|
|
78
|
+
ezprinter.error("Missing required option: --label")
|
|
79
|
+
ezprinter.info("Use --interactive for guided setup")
|
|
80
|
+
return None
|
|
81
|
+
|
|
82
|
+
resolved_icon = icon if isinstance(icon, str) and icon else "auto"
|
|
83
|
+
context_params = ContextParameters.from_flags(
|
|
84
|
+
root=root,
|
|
85
|
+
file=file,
|
|
86
|
+
files=files,
|
|
87
|
+
background=background,
|
|
88
|
+
file_types=list(file_types) if file_types else None,
|
|
89
|
+
extensions=list(extensions) if extensions else None,
|
|
90
|
+
)
|
|
91
|
+
return target_path, label, resolved_icon, context_params
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# ///////////////////////////////////////////////////////////////
|
|
95
|
+
# REGISTRATION COMMANDS
|
|
96
|
+
# ///////////////////////////////////////////////////////////////
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@context_group.command("register")
|
|
100
|
+
@click.help_option("-h", "--help")
|
|
101
|
+
@click.option(
|
|
102
|
+
"--target",
|
|
103
|
+
"target_path",
|
|
104
|
+
type=click.Path(),
|
|
105
|
+
help="Script or executable to register in context menu",
|
|
106
|
+
)
|
|
107
|
+
@click.option(
|
|
108
|
+
"-l",
|
|
109
|
+
"--label",
|
|
110
|
+
help="Label to display in context menu",
|
|
111
|
+
)
|
|
112
|
+
@click.option(
|
|
113
|
+
"--icon",
|
|
114
|
+
default="auto",
|
|
115
|
+
help="Icon path or 'auto' for auto-detection (default: auto)",
|
|
116
|
+
)
|
|
117
|
+
@click.option(
|
|
118
|
+
"--root",
|
|
119
|
+
is_flag=True,
|
|
120
|
+
help="Register for root directories (drives) only",
|
|
121
|
+
)
|
|
122
|
+
@click.option(
|
|
123
|
+
"--file",
|
|
124
|
+
is_flag=True,
|
|
125
|
+
help="Register for single file selection",
|
|
126
|
+
)
|
|
127
|
+
@click.option(
|
|
128
|
+
"-F",
|
|
129
|
+
"--files",
|
|
130
|
+
is_flag=True,
|
|
131
|
+
help="Register for multiple file selection",
|
|
132
|
+
)
|
|
133
|
+
@click.option(
|
|
134
|
+
"--background",
|
|
135
|
+
is_flag=True,
|
|
136
|
+
help="Register for background context only",
|
|
137
|
+
)
|
|
138
|
+
@click.option(
|
|
139
|
+
"--file-types",
|
|
140
|
+
multiple=True,
|
|
141
|
+
help="File types to register for (e.g., image, text, archive)",
|
|
142
|
+
)
|
|
143
|
+
@click.option(
|
|
144
|
+
"--extension",
|
|
145
|
+
"extensions",
|
|
146
|
+
multiple=True,
|
|
147
|
+
help="Custom file extensions (e.g., .py, .js)",
|
|
148
|
+
)
|
|
149
|
+
@click.option(
|
|
150
|
+
"-I",
|
|
151
|
+
"--interactive",
|
|
152
|
+
is_flag=True,
|
|
153
|
+
help="Interactive mode - guided setup",
|
|
154
|
+
)
|
|
155
|
+
@click.option(
|
|
156
|
+
"-v",
|
|
157
|
+
"--verbose",
|
|
158
|
+
is_flag=True,
|
|
159
|
+
help="Verbose mode",
|
|
160
|
+
)
|
|
161
|
+
def context_register(
|
|
162
|
+
target_path: str | None,
|
|
163
|
+
label: str | None,
|
|
164
|
+
icon: str,
|
|
165
|
+
root: bool,
|
|
166
|
+
file: bool,
|
|
167
|
+
files: bool,
|
|
168
|
+
background: bool,
|
|
169
|
+
file_types: tuple[str, ...],
|
|
170
|
+
extensions: tuple[str, ...],
|
|
171
|
+
interactive: bool,
|
|
172
|
+
verbose: bool,
|
|
173
|
+
) -> None:
|
|
174
|
+
"""📝 Register scripts in Windows context menu."""
|
|
175
|
+
if verbose:
|
|
176
|
+
ezpl.set_level(LogLevel.DEBUG.label)
|
|
177
|
+
|
|
178
|
+
ezprinter.print_header("Context Menu Registration")
|
|
179
|
+
|
|
180
|
+
manager = ContextMenuInterface()
|
|
181
|
+
|
|
182
|
+
if not _check_windows(manager):
|
|
183
|
+
ezprinter.info("Consider using symbolic links or aliases on Unix systems")
|
|
184
|
+
sys.exit(1)
|
|
185
|
+
|
|
186
|
+
resolved = _resolve_registration_target(
|
|
187
|
+
target_path,
|
|
188
|
+
label,
|
|
189
|
+
icon,
|
|
190
|
+
root,
|
|
191
|
+
file,
|
|
192
|
+
files,
|
|
193
|
+
background,
|
|
194
|
+
file_types,
|
|
195
|
+
extensions,
|
|
196
|
+
interactive,
|
|
197
|
+
)
|
|
198
|
+
if resolved is None:
|
|
199
|
+
if interactive:
|
|
200
|
+
ezprinter.info("Registration cancelled")
|
|
201
|
+
return
|
|
202
|
+
sys.exit(1)
|
|
203
|
+
resolved_target, resolved_label, resolved_icon, context_params = resolved
|
|
204
|
+
|
|
205
|
+
if verbose:
|
|
206
|
+
ezprinter.info(f"Target: {resolved_target}")
|
|
207
|
+
ezprinter.info(f"Label: {resolved_label}")
|
|
208
|
+
ezprinter.info(f"Icon: {resolved_icon}")
|
|
209
|
+
if context_params:
|
|
210
|
+
ezprinter.info(f"Context: {context_params.get_description()}")
|
|
211
|
+
|
|
212
|
+
backup_dir = manager.get_backup_directory()
|
|
213
|
+
backup_file = str(backup_dir / "context_menu_backup_before_register.json")
|
|
214
|
+
with ezwizard.spinner_with_status("Creating backup before registration...") as (
|
|
215
|
+
progress,
|
|
216
|
+
task,
|
|
217
|
+
):
|
|
218
|
+
progress.update(task, status="Creating backup...")
|
|
219
|
+
backup_result = manager.backup_entries(backup_file)
|
|
220
|
+
|
|
221
|
+
if not backup_result.success:
|
|
222
|
+
ezprinter.error(f"Backup failed: {backup_result.error}")
|
|
223
|
+
sys.exit(1)
|
|
224
|
+
|
|
225
|
+
if verbose:
|
|
226
|
+
ezprinter.info(f"Backup created: {backup_file}")
|
|
227
|
+
|
|
228
|
+
with ezwizard.spinner_with_status("Registering script in context menu...") as (
|
|
229
|
+
progress,
|
|
230
|
+
task,
|
|
231
|
+
):
|
|
232
|
+
progress.update(task, status="Adding registry entries...")
|
|
233
|
+
result = manager.register_script(
|
|
234
|
+
resolved_target, resolved_label, resolved_icon, False, context_params
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
render_script_registration_result(result)
|
|
238
|
+
sys.exit(0 if result.success else 1)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# ///////////////////////////////////////////////////////////////
|
|
242
|
+
# UNREGISTRATION COMMANDS
|
|
243
|
+
# ///////////////////////////////////////////////////////////////
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
@context_group.command("unregister")
|
|
247
|
+
@click.help_option("-h", "--help")
|
|
248
|
+
@click.option(
|
|
249
|
+
"--remove",
|
|
250
|
+
"remove_key",
|
|
251
|
+
required=True,
|
|
252
|
+
help="Key name to remove (as stored in registry)",
|
|
253
|
+
)
|
|
254
|
+
@click.option(
|
|
255
|
+
"-v",
|
|
256
|
+
"--verbose",
|
|
257
|
+
is_flag=True,
|
|
258
|
+
help="Enable verbose output (DEBUG level)",
|
|
259
|
+
)
|
|
260
|
+
def context_unregister(remove_key: str, verbose: bool) -> None:
|
|
261
|
+
"""🗑️ Unregister scripts from Windows context menu."""
|
|
262
|
+
if verbose:
|
|
263
|
+
ezpl.set_level(LogLevel.DEBUG.label)
|
|
264
|
+
|
|
265
|
+
ezprinter.print_header("Context Menu Unregistration")
|
|
266
|
+
|
|
267
|
+
manager = ContextMenuInterface()
|
|
268
|
+
|
|
269
|
+
if not _check_windows(manager):
|
|
270
|
+
return
|
|
271
|
+
|
|
272
|
+
if verbose:
|
|
273
|
+
ezprinter.info(f"Removing key: {remove_key}")
|
|
274
|
+
|
|
275
|
+
with ezwizard.spinner_with_status("Unregistering script from context menu...") as (
|
|
276
|
+
progress,
|
|
277
|
+
task,
|
|
278
|
+
):
|
|
279
|
+
progress.update(task, status="Removing registry entries...")
|
|
280
|
+
result = manager.unregister_script(remove_key)
|
|
281
|
+
|
|
282
|
+
render_script_unregistration_result(result)
|
|
283
|
+
sys.exit(0 if result.success else 1)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
# ///////////////////////////////////////////////////////////////
|
|
287
|
+
# PUBLIC API
|
|
288
|
+
# ///////////////////////////////////////////////////////////////
|
|
289
|
+
|
|
290
|
+
__all__ = ["context_register", "context_unregister"]
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# DEPS COMMAND - Dependencies Diagnostic
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Dependencies command for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
Read-only diagnostic across the 2-strata dependency model:
|
|
11
|
+
- Strata 1: Runtimes (python, node, git)
|
|
12
|
+
- Strata 2: Runtime package managers (pip, uv, npm, yarn)
|
|
13
|
+
|
|
14
|
+
Installation is intentionally out of scope: WOMM reports what is present on the
|
|
15
|
+
machine, it does not install runtimes for you. System package managers (winget,
|
|
16
|
+
homebrew, apt) and a project's own packages are out of scope too.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
# ///////////////////////////////////////////////////////////////
|
|
22
|
+
# IMPORTS
|
|
23
|
+
# ///////////////////////////////////////////////////////////////
|
|
24
|
+
# Standard library imports
|
|
25
|
+
import sys
|
|
26
|
+
|
|
27
|
+
# Third-party imports
|
|
28
|
+
import click
|
|
29
|
+
from ezplog import LogLevel
|
|
30
|
+
|
|
31
|
+
# Local imports
|
|
32
|
+
from ...interfaces import DepsInterface
|
|
33
|
+
from ...ui.common import ezpl, ezprinter
|
|
34
|
+
from ...ui.system import (
|
|
35
|
+
render_deps_check_result,
|
|
36
|
+
render_deps_inventory_result,
|
|
37
|
+
render_deps_status_result,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# ///////////////////////////////////////////////////////////////
|
|
41
|
+
# MAIN DEPS GROUP
|
|
42
|
+
# ///////////////////////////////////////////////////////////////
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@click.group(invoke_without_command=True)
|
|
46
|
+
@click.pass_context
|
|
47
|
+
def deps_group(ctx: click.Context) -> None:
|
|
48
|
+
"""
|
|
49
|
+
Inspect the runtimes and runtime package managers WOMM relies on.
|
|
50
|
+
|
|
51
|
+
The dependency model has 2 hierarchical strata:
|
|
52
|
+
|
|
53
|
+
\b
|
|
54
|
+
Strata 1: Runtimes (python, node, git)
|
|
55
|
+
Strata 2: Runtime package managers (pip, uv, npm, yarn)
|
|
56
|
+
|
|
57
|
+
This command is read-only: it reports what is installed, it does not
|
|
58
|
+
install anything. Use your OS package manager to install what is missing.
|
|
59
|
+
"""
|
|
60
|
+
if ctx.invoked_subcommand is None:
|
|
61
|
+
click.echo(ctx.get_help())
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# ///////////////////////////////////////////////////////////////
|
|
65
|
+
# COMMANDS
|
|
66
|
+
# ///////////////////////////////////////////////////////////////
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@deps_group.command(name="check")
|
|
70
|
+
@click.help_option("-h", "--help")
|
|
71
|
+
@click.option(
|
|
72
|
+
"-v",
|
|
73
|
+
"--verbose",
|
|
74
|
+
is_flag=True,
|
|
75
|
+
help="Show version details for each component.",
|
|
76
|
+
)
|
|
77
|
+
def deps_check(verbose: bool) -> None:
|
|
78
|
+
"""
|
|
79
|
+
🔍 Check availability of all dependencies across both strata.
|
|
80
|
+
|
|
81
|
+
Probes the runtimes and the runtime package managers, then reports which
|
|
82
|
+
are present. Exit status is 0 when every runtime is installed and at least
|
|
83
|
+
one runtime package manager is available.
|
|
84
|
+
|
|
85
|
+
\b
|
|
86
|
+
Example:
|
|
87
|
+
womm deps check
|
|
88
|
+
womm deps check -v
|
|
89
|
+
"""
|
|
90
|
+
if verbose:
|
|
91
|
+
ezpl.set_level(LogLevel.DEBUG.label)
|
|
92
|
+
|
|
93
|
+
ezprinter.print_header("Dependencies Check")
|
|
94
|
+
|
|
95
|
+
result = DepsInterface().check_all(detect_versions=verbose)
|
|
96
|
+
render_deps_check_result(result, verbose)
|
|
97
|
+
if not result.success:
|
|
98
|
+
sys.exit(1)
|
|
99
|
+
sys.exit(0 if (result.runtime_ok and result.package_managers_ok) else 1)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@deps_group.command(name="status")
|
|
103
|
+
@click.help_option("-h", "--help")
|
|
104
|
+
@click.option(
|
|
105
|
+
"-v",
|
|
106
|
+
"--verbose",
|
|
107
|
+
is_flag=True,
|
|
108
|
+
help="Show additional details in the status report.",
|
|
109
|
+
)
|
|
110
|
+
def deps_status(verbose: bool) -> None:
|
|
111
|
+
"""
|
|
112
|
+
📊 Show a comprehensive dependency status table.
|
|
113
|
+
|
|
114
|
+
Renders a table with the status of every component across the two
|
|
115
|
+
strata, including versions and availability.
|
|
116
|
+
|
|
117
|
+
\b
|
|
118
|
+
Example:
|
|
119
|
+
womm deps status
|
|
120
|
+
womm deps status -v
|
|
121
|
+
"""
|
|
122
|
+
if verbose:
|
|
123
|
+
ezpl.set_level(LogLevel.DEBUG.label)
|
|
124
|
+
|
|
125
|
+
ezprinter.print_header("Dependency Status")
|
|
126
|
+
|
|
127
|
+
result = DepsInterface().show_status(detect_versions=verbose)
|
|
128
|
+
render_deps_status_result(result, verbose)
|
|
129
|
+
sys.exit(0 if result.success else 1)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@deps_group.command(name="list")
|
|
133
|
+
@click.help_option("-h", "--help")
|
|
134
|
+
@click.option(
|
|
135
|
+
"-v",
|
|
136
|
+
"--verbose",
|
|
137
|
+
is_flag=True,
|
|
138
|
+
help="Reserved for future use.",
|
|
139
|
+
)
|
|
140
|
+
def deps_list(verbose: bool) -> None:
|
|
141
|
+
"""
|
|
142
|
+
📋 List the dependencies WOMM knows about (static inventory).
|
|
143
|
+
|
|
144
|
+
Shows the configured runtimes and runtime package managers, without
|
|
145
|
+
probing the machine.
|
|
146
|
+
|
|
147
|
+
\b
|
|
148
|
+
Example:
|
|
149
|
+
womm deps list
|
|
150
|
+
"""
|
|
151
|
+
if verbose:
|
|
152
|
+
ezpl.set_level(LogLevel.DEBUG.label)
|
|
153
|
+
|
|
154
|
+
ezprinter.print_header("Dependency Inventory")
|
|
155
|
+
|
|
156
|
+
result = DepsInterface().list_all()
|
|
157
|
+
render_deps_inventory_result(result)
|
|
158
|
+
sys.exit(0 if result.success else 1)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
# ///////////////////////////////////////////////////////////////
|
|
162
|
+
# EXPORT
|
|
163
|
+
# ///////////////////////////////////////////////////////////////
|
|
164
|
+
|
|
165
|
+
__all__ = ["deps_group"]
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# SYSTEM - System Commands
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
System commands for WOMM CLI.
|
|
9
|
+
|
|
10
|
+
This module handles system detection and environment refresh. It owns the
|
|
11
|
+
presentation (headers, spinners, renderers) and drives the interfaces, which
|
|
12
|
+
return Result objects.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
# ///////////////////////////////////////////////////////////////
|
|
18
|
+
# IMPORTS
|
|
19
|
+
# ///////////////////////////////////////////////////////////////
|
|
20
|
+
# Standard library imports
|
|
21
|
+
import sys
|
|
22
|
+
|
|
23
|
+
# Third-party imports
|
|
24
|
+
import click
|
|
25
|
+
from ezplog import LogLevel
|
|
26
|
+
from rich.progress import TaskID
|
|
27
|
+
|
|
28
|
+
# Local imports
|
|
29
|
+
from ...interfaces import SystemDetectorInterface, SystemEnvironmentInterface
|
|
30
|
+
from ...ui.common import ezpl, ezprinter, ezwizard
|
|
31
|
+
from ...ui.system import (
|
|
32
|
+
render_environment_refresh_result,
|
|
33
|
+
render_system_detection_result,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# ///////////////////////////////////////////////////////////////
|
|
37
|
+
# COMMAND GROUPS
|
|
38
|
+
# ///////////////////////////////////////////////////////////////
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@click.group(invoke_without_command=True)
|
|
42
|
+
@click.pass_context
|
|
43
|
+
def system_group(ctx: click.Context) -> None:
|
|
44
|
+
"""System detection and prerequisites."""
|
|
45
|
+
if ctx.invoked_subcommand is None:
|
|
46
|
+
click.echo(ctx.get_help())
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# ///////////////////////////////////////////////////////////////
|
|
50
|
+
# SYSTEM DETECTION COMMANDS
|
|
51
|
+
# ///////////////////////////////////////////////////////////////
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@system_group.command("detect")
|
|
55
|
+
@click.help_option("-h", "--help")
|
|
56
|
+
@click.option(
|
|
57
|
+
"-v",
|
|
58
|
+
"--verbose",
|
|
59
|
+
is_flag=True,
|
|
60
|
+
help="Enable verbose output (DEBUG level)",
|
|
61
|
+
)
|
|
62
|
+
def system_detect(verbose: bool) -> None:
|
|
63
|
+
"""🔍 Detect system information and available tools."""
|
|
64
|
+
if verbose:
|
|
65
|
+
ezpl.set_level(LogLevel.DEBUG.label)
|
|
66
|
+
|
|
67
|
+
ezprinter.print_header("System Detection")
|
|
68
|
+
|
|
69
|
+
interface = SystemDetectorInterface()
|
|
70
|
+
with ezwizard.spinner_with_status("Detecting system information...") as (
|
|
71
|
+
progress,
|
|
72
|
+
task,
|
|
73
|
+
):
|
|
74
|
+
task_id = TaskID(task)
|
|
75
|
+
progress.update(
|
|
76
|
+
task_id,
|
|
77
|
+
description="🔍 Detecting system information...",
|
|
78
|
+
status="Scanning system...",
|
|
79
|
+
)
|
|
80
|
+
result = interface.detect_system()
|
|
81
|
+
progress.update(task_id, status="Detection complete!")
|
|
82
|
+
|
|
83
|
+
render_system_detection_result(result)
|
|
84
|
+
sys.exit(0 if result.success else 1)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# ///////////////////////////////////////////////////////////////
|
|
88
|
+
# ENVIRONMENT MANAGEMENT COMMANDS
|
|
89
|
+
# ///////////////////////////////////////////////////////////////
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@system_group.command("refresh-env")
|
|
93
|
+
@click.help_option("-h", "--help")
|
|
94
|
+
@click.option(
|
|
95
|
+
"-v",
|
|
96
|
+
"--verbose",
|
|
97
|
+
is_flag=True,
|
|
98
|
+
help="Enable verbose output (DEBUG level)",
|
|
99
|
+
)
|
|
100
|
+
def system_refresh_env(verbose: bool) -> None:
|
|
101
|
+
"""🔄 Refresh environment variables (Windows only)."""
|
|
102
|
+
if verbose:
|
|
103
|
+
ezpl.set_level(LogLevel.DEBUG.label)
|
|
104
|
+
|
|
105
|
+
ezprinter.print_header("Environment Refresh")
|
|
106
|
+
|
|
107
|
+
interface = SystemEnvironmentInterface()
|
|
108
|
+
with ezwizard.spinner_with_status("Refreshing environment variables...") as (
|
|
109
|
+
progress,
|
|
110
|
+
task,
|
|
111
|
+
):
|
|
112
|
+
task_id = TaskID(task)
|
|
113
|
+
progress.update(
|
|
114
|
+
task_id,
|
|
115
|
+
description="Refreshing environment variables...",
|
|
116
|
+
status="Reading registry/system configuration...",
|
|
117
|
+
)
|
|
118
|
+
result = interface.refresh_environment()
|
|
119
|
+
progress.update(
|
|
120
|
+
task_id,
|
|
121
|
+
status=(
|
|
122
|
+
"Environment refreshed successfully!"
|
|
123
|
+
if result.success
|
|
124
|
+
else "Environment refresh failed."
|
|
125
|
+
),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
accessible = interface.verify_environment_refresh() if result.success else False
|
|
129
|
+
render_environment_refresh_result(result, accessible)
|
|
130
|
+
sys.exit(0 if result.success else 1)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# EXCEPTIONS - Custom Exceptions by Domain
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Custom exceptions for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This package contains all custom exceptions organized by domain.
|
|
11
|
+
Import exceptions from the appropriate domain:
|
|
12
|
+
|
|
13
|
+
from exceptions.common import CommandServiceError, FileServiceError
|
|
14
|
+
from exceptions.context import ContextServiceError
|
|
15
|
+
from exceptions.project import ProjectServiceError
|
|
16
|
+
from exceptions.system import SystemServiceError
|
|
17
|
+
|
|
18
|
+
Available domains:
|
|
19
|
+
- common: Command, file, and security service exceptions
|
|
20
|
+
- context: Context menu service exceptions
|
|
21
|
+
- project: Project management exceptions
|
|
22
|
+
- system: System management exceptions
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
# ///////////////////////////////////////////////////////////////
|
|
28
|
+
# IMPORTS BY DOMAIN
|
|
29
|
+
# ///////////////////////////////////////////////////////////////
|
|
30
|
+
# Local imports - Common exceptions
|
|
31
|
+
from .common import (
|
|
32
|
+
CommandExecutionError,
|
|
33
|
+
CommandServiceError,
|
|
34
|
+
CommandTimeoutError,
|
|
35
|
+
CommandUtilityError,
|
|
36
|
+
FileServiceError,
|
|
37
|
+
SecurityServiceError,
|
|
38
|
+
ValidationServiceError,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# Local imports - Context exceptions
|
|
42
|
+
from .context import ContextServiceError
|
|
43
|
+
|
|
44
|
+
# Local imports - Project exceptions
|
|
45
|
+
from .project import ProjectServiceError
|
|
46
|
+
|
|
47
|
+
# Local imports - System exceptions
|
|
48
|
+
from .system import SystemServiceError
|
|
49
|
+
|
|
50
|
+
# ///////////////////////////////////////////////////////////////
|
|
51
|
+
# PUBLIC API - All Exceptions
|
|
52
|
+
# ///////////////////////////////////////////////////////////////
|
|
53
|
+
|
|
54
|
+
__all__ = [ # noqa: RUF022
|
|
55
|
+
# Common exceptions
|
|
56
|
+
"CommandExecutionError",
|
|
57
|
+
"CommandServiceError",
|
|
58
|
+
"CommandUtilityError",
|
|
59
|
+
"FileServiceError",
|
|
60
|
+
"SecurityServiceError",
|
|
61
|
+
"CommandTimeoutError",
|
|
62
|
+
"ValidationServiceError",
|
|
63
|
+
# Context exceptions
|
|
64
|
+
"ContextServiceError",
|
|
65
|
+
# Project exceptions
|
|
66
|
+
"ProjectServiceError",
|
|
67
|
+
# System exceptions
|
|
68
|
+
"SystemServiceError",
|
|
69
|
+
]
|