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.
Files changed (218) hide show
  1. womm/__init__.py +53 -0
  2. womm/__main__.py +48 -0
  3. womm/_version.py +10 -0
  4. womm/assets/copier/meta/copier.yml +15 -0
  5. womm/assets/copier/meta/template/README.md.jinja +32 -0
  6. womm/assets/copier/meta/template/copier.yml.jinja +13 -0
  7. womm/assets/copier/meta/template/template/.gitkeep +0 -0
  8. womm/assets/copier/official/javascript/copier.yml +104 -0
  9. womm/assets/copier/official/javascript/template/.gitignore.jinja +35 -0
  10. womm/assets/copier/official/javascript/template/.nvmrc.jinja +1 -0
  11. womm/assets/copier/official/javascript/template/.prettierignore.jinja +10 -0
  12. womm/assets/copier/official/javascript/template/README.md.jinja +81 -0
  13. womm/assets/copier/official/javascript/template/biome.json.jinja +54 -0
  14. womm/assets/copier/official/javascript/template/eslint.config.mjs.jinja +51 -0
  15. womm/assets/copier/official/javascript/template/index.html.jinja +12 -0
  16. womm/assets/copier/official/javascript/template/package.json.jinja +88 -0
  17. womm/assets/copier/official/javascript/template/prettier.config.mjs.jinja +8 -0
  18. womm/assets/copier/official/javascript/template/src/App.jsx.jinja +10 -0
  19. womm/assets/copier/official/javascript/template/src/App.tsx.jinja +10 -0
  20. womm/assets/copier/official/javascript/template/src/App.vue.jinja +18 -0
  21. womm/assets/copier/official/javascript/template/src/index.jsx.jinja +10 -0
  22. womm/assets/copier/official/javascript/template/src/index.tsx.jinja +11 -0
  23. womm/assets/copier/official/javascript/template/src/main.js.jinja +21 -0
  24. womm/assets/copier/official/javascript/template/src/main.ts.jinja +21 -0
  25. womm/assets/copier/official/javascript/template/tsconfig.json.jinja +35 -0
  26. womm/assets/copier/official/javascript/template/vite.config.mjs.jinja +10 -0
  27. womm/assets/copier/official/javascript/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +63 -0
  28. womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.js.jinja +12 -0
  29. womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.ts.jinja +12 -0
  30. womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +4 -0
  31. womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +27 -0
  32. womm/assets/copier/official/python/copier.yml +107 -0
  33. womm/assets/copier/official/python/template/.gitignore.jinja +40 -0
  34. womm/assets/copier/official/python/template/.pre-commit-config.yaml.jinja +19 -0
  35. womm/assets/copier/official/python/template/.python-version.jinja +1 -0
  36. womm/assets/copier/official/python/template/README.md.jinja +83 -0
  37. womm/assets/copier/official/python/template/pyproject.toml.jinja +114 -0
  38. womm/assets/copier/official/python/template/{% if framework == 'django' %}manage.py{% endif %}.jinja +23 -0
  39. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/__init__.py.jinja +3 -0
  40. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/asgi.py.jinja +9 -0
  41. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/__init__.py.jinja +0 -0
  42. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/apps.py.jinja +10 -0
  43. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/models.py.jinja +1 -0
  44. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/views.py.jinja +8 -0
  45. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/py.typed +0 -0
  46. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/settings.py.jinja +81 -0
  47. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/urls.py.jinja +11 -0
  48. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/wsgi.py.jinja +9 -0
  49. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/__init__.py.jinja +3 -0
  50. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/asgi.py.jinja +9 -0
  51. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/__init__.py.jinja +0 -0
  52. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/apps.py.jinja +10 -0
  53. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/models.py.jinja +1 -0
  54. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/views.py.jinja +8 -0
  55. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/py.typed +0 -0
  56. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/settings.py.jinja +81 -0
  57. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/urls.py.jinja +11 -0
  58. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/wsgi.py.jinja +9 -0
  59. womm/assets/copier/official/python/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +78 -0
  60. womm/assets/copier/official/python/template/{% if with_tests %}tests{% endif %}/test_smoke.py.jinja +16 -0
  61. womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +8 -0
  62. womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +28 -0
  63. womm/bin/refresh_env.cmd +130 -0
  64. womm/cli.py +111 -0
  65. womm/commands/__init__.py +30 -0
  66. womm/commands/core/__init__.py +29 -0
  67. womm/commands/core/doctor.py +52 -0
  68. womm/commands/core/path.py +337 -0
  69. womm/commands/project/__init__.py +31 -0
  70. womm/commands/project/create.py +128 -0
  71. womm/commands/project/setup.py +438 -0
  72. womm/commands/project/template.py +160 -0
  73. womm/commands/system/__init__.py +31 -0
  74. womm/commands/system/context/__init__.py +82 -0
  75. womm/commands/system/context/backup.py +344 -0
  76. womm/commands/system/context/inventory.py +111 -0
  77. womm/commands/system/context/registration.py +290 -0
  78. womm/commands/system/deps.py +165 -0
  79. womm/commands/system/system.py +130 -0
  80. womm/exceptions/__init__.py +69 -0
  81. womm/exceptions/common/__init__.py +55 -0
  82. womm/exceptions/common/command_service.py +91 -0
  83. womm/exceptions/common/file_service.py +60 -0
  84. womm/exceptions/common/security_service.py +44 -0
  85. womm/exceptions/common/validation_service.py +70 -0
  86. womm/exceptions/context/__init__.py +27 -0
  87. womm/exceptions/context/context_service.py +55 -0
  88. womm/exceptions/project/__init__.py +29 -0
  89. womm/exceptions/project/project_service.py +59 -0
  90. womm/exceptions/system/__init__.py +25 -0
  91. womm/exceptions/system/system_service.py +53 -0
  92. womm/interfaces/__init__.py +71 -0
  93. womm/interfaces/context/__init__.py +34 -0
  94. womm/interfaces/context/menu_interface.py +686 -0
  95. womm/interfaces/context/registry_interface.py +562 -0
  96. womm/interfaces/context/script_detector_interface.py +208 -0
  97. womm/interfaces/context/script_registrar.py +264 -0
  98. womm/interfaces/core/__init__.py +26 -0
  99. womm/interfaces/core/doctor_interface.py +102 -0
  100. womm/interfaces/dependencies/__init__.py +28 -0
  101. womm/interfaces/dependencies/deps_interface.py +160 -0
  102. womm/interfaces/project/__init__.py +36 -0
  103. womm/interfaces/project/create_interface.py +162 -0
  104. womm/interfaces/project/detection_interface.py +181 -0
  105. womm/interfaces/project/manager_interface.py +99 -0
  106. womm/interfaces/project/setup_interface.py +477 -0
  107. womm/interfaces/project/template_store_interface.py +196 -0
  108. womm/interfaces/system/__init__.py +32 -0
  109. womm/interfaces/system/detector_interface.py +84 -0
  110. womm/interfaces/system/environment_interface.py +110 -0
  111. womm/interfaces/system/path_interface.py +570 -0
  112. womm/services/__init__.py +70 -0
  113. womm/services/common/__init__.py +33 -0
  114. womm/services/common/base_validation_service.py +450 -0
  115. womm/services/common/command_runner_service.py +647 -0
  116. womm/services/common/file_scanner_service.py +483 -0
  117. womm/services/common/security_validator_service.py +348 -0
  118. womm/services/context/__init__.py +37 -0
  119. womm/services/context/backup_entries.py +148 -0
  120. womm/services/context/parameters.py +515 -0
  121. womm/services/context/registry_paths.py +56 -0
  122. womm/services/context/registry_service.py +573 -0
  123. womm/services/context/validation_service.py +691 -0
  124. womm/services/dependencies/__init__.py +29 -0
  125. womm/services/dependencies/probe.py +102 -0
  126. womm/services/project/__init__.py +48 -0
  127. womm/services/project/copier_project_creation_service.py +111 -0
  128. womm/services/project/destination_guard.py +96 -0
  129. womm/services/project/detection_service.py +354 -0
  130. womm/services/project/env_utils.py +333 -0
  131. womm/services/project/javascript_environment_service.py +348 -0
  132. womm/services/project/python_environment_service.py +245 -0
  133. womm/services/project/setup_profile_resolver.py +146 -0
  134. womm/services/project/template_store_service.py +344 -0
  135. womm/services/project/validation_service.py +418 -0
  136. womm/services/system/__init__.py +32 -0
  137. womm/services/system/detector_service.py +704 -0
  138. womm/services/system/environment_service.py +494 -0
  139. womm/services/system/path_service.py +642 -0
  140. womm/shared/__init__.py +30 -0
  141. womm/shared/configs/__init__.py +51 -0
  142. womm/shared/configs/context/__init__.py +43 -0
  143. womm/shared/configs/context/context_config.py +125 -0
  144. womm/shared/configs/context/context_file_types_config.py +159 -0
  145. womm/shared/configs/context/context_limits_config.py +187 -0
  146. womm/shared/configs/context/context_paths_config.py +115 -0
  147. womm/shared/configs/context/context_types_config.py +65 -0
  148. womm/shared/configs/context/script_config.py +219 -0
  149. womm/shared/configs/dependencies/__init__.py +32 -0
  150. womm/shared/configs/dependencies/runtime_config.py +46 -0
  151. womm/shared/configs/dependencies/runtime_package_manager_config.py +48 -0
  152. womm/shared/configs/logging_config.py +89 -0
  153. womm/shared/configs/project/__init__.py +33 -0
  154. womm/shared/configs/project/project_config.py +109 -0
  155. womm/shared/configs/project/project_structure_config.py +88 -0
  156. womm/shared/configs/project/python_project_config.py +165 -0
  157. womm/shared/configs/security/__init__.py +26 -0
  158. womm/shared/configs/security/security_patterns_config.py +242 -0
  159. womm/shared/configs/system/__init__.py +28 -0
  160. womm/shared/configs/system/system_detector_config.py +210 -0
  161. womm/shared/configs/system/system_environment_config.py +101 -0
  162. womm/shared/models/__init__.py +13 -0
  163. womm/shared/models/template_source.py +65 -0
  164. womm/shared/paths.py +192 -0
  165. womm/shared/results/__init__.py +138 -0
  166. womm/shared/results/base.py +85 -0
  167. womm/shared/results/command_results.py +61 -0
  168. womm/shared/results/context_results.py +345 -0
  169. womm/shared/results/dependency_results.py +110 -0
  170. womm/shared/results/doctor_results.py +41 -0
  171. womm/shared/results/file_results.py +97 -0
  172. womm/shared/results/project_results.py +163 -0
  173. womm/shared/results/security_results.py +128 -0
  174. womm/shared/results/system_results.py +268 -0
  175. womm/shared/results/template_results.py +43 -0
  176. womm/shared/runtime.py +36 -0
  177. womm/ui/__init__.py +31 -0
  178. womm/ui/common/__init__.py +39 -0
  179. womm/ui/common/interactive_menu.py +246 -0
  180. womm/ui/common/logging.py +184 -0
  181. womm/ui/common/prompts.py +93 -0
  182. womm/ui/context/__init__.py +31 -0
  183. womm/ui/context/display.py +485 -0
  184. womm/ui/context/menu_display.py +189 -0
  185. womm/ui/context/wizard.py +557 -0
  186. womm/ui/project/__init__.py +42 -0
  187. womm/ui/project/create/create_completion_summaries.py +55 -0
  188. womm/ui/project/project_wizard.py +174 -0
  189. womm/ui/project/setup/setup_completion_summaries.py +111 -0
  190. womm/ui/project/templates/template_store_display.py +128 -0
  191. womm/ui/system/__init__.py +60 -0
  192. womm/ui/system/display.py +531 -0
  193. womm/ui/system/path_display.py +387 -0
  194. womm/utils/__init__.py +23 -0
  195. womm/utils/common/__init__.py +49 -0
  196. womm/utils/common/file_scanner_utils.py +110 -0
  197. womm/utils/common/path_resolver_utils.py +127 -0
  198. womm/utils/common/safe_fs_utils.py +135 -0
  199. womm/utils/context/__init__.py +54 -0
  200. womm/utils/context/core_utils.py +345 -0
  201. womm/utils/context/icon_utils.py +259 -0
  202. womm/utils/project/__init__.py +106 -0
  203. womm/utils/project/asset_utils.py +154 -0
  204. womm/utils/project/core_utils.py +391 -0
  205. womm/utils/project/file_utils.py +494 -0
  206. womm/utils/project/platform_utils.py +170 -0
  207. womm/utils/project/validation_utils.py +273 -0
  208. womm/utils/security/__init__.py +46 -0
  209. womm/utils/security/security_validation_utils.py +258 -0
  210. womm/utils/system/__init__.py +69 -0
  211. womm/utils/system/detector_utils.py +299 -0
  212. womm/utils/system/environment_utils.py +172 -0
  213. womm/utils/system/path_utils.py +101 -0
  214. womm_cli-4.0.0.dist-info/METADATA +203 -0
  215. womm_cli-4.0.0.dist-info/RECORD +218 -0
  216. womm_cli-4.0.0.dist-info/WHEEL +4 -0
  217. womm_cli-4.0.0.dist-info/entry_points.txt +2 -0
  218. womm_cli-4.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env python3
2
+ # ///////////////////////////////////////////////////////////////
3
+ # CONTEXT - Context Menu Command Group
4
+ # Project: works-on-my-machine
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ """
8
+ Context menu commands for WOMM CLI.
9
+
10
+ Wires the ``context`` group and its ``backup`` subgroup. The commands
11
+ themselves live in the sibling modules, grouped by responsibility.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ # ///////////////////////////////////////////////////////////////
17
+ # IMPORTS
18
+ # ///////////////////////////////////////////////////////////////
19
+ # Third-party imports
20
+ import click
21
+
22
+ # Local imports
23
+ from ....interfaces import ContextMenuInterface
24
+ from ....ui.common import ezprinter
25
+
26
+ # ///////////////////////////////////////////////////////////////
27
+ # CONSTANTS
28
+ # ///////////////////////////////////////////////////////////////
29
+
30
+ _NON_WINDOWS_MESSAGE = "Context menu management is Windows-specific"
31
+
32
+ # ///////////////////////////////////////////////////////////////
33
+ # COMMAND GROUPS
34
+ # ///////////////////////////////////////////////////////////////
35
+
36
+
37
+ @click.group(invoke_without_command=True)
38
+ @click.pass_context
39
+ def context_group(ctx: click.Context) -> None:
40
+ """Windows context menu management."""
41
+ if ctx.invoked_subcommand is None:
42
+ click.echo(ctx.get_help())
43
+
44
+
45
+ @context_group.group("backup", invoke_without_command=True)
46
+ @click.help_option("-h", "--help")
47
+ @click.pass_context
48
+ def context_backup_group(ctx: click.Context) -> None:
49
+ """Manage context menu backups."""
50
+ if ctx.invoked_subcommand is None:
51
+ click.echo(ctx.get_help())
52
+
53
+
54
+ # ///////////////////////////////////////////////////////////////
55
+ # FUNCTIONS
56
+ # ///////////////////////////////////////////////////////////////
57
+
58
+
59
+ def _check_windows(manager: ContextMenuInterface) -> bool:
60
+ """Print the non-Windows notice and report support status.
61
+
62
+ Args:
63
+ manager: Interface used to detect the platform.
64
+
65
+ Returns:
66
+ True when running on Windows, False otherwise.
67
+ """
68
+ if manager.is_windows():
69
+ return True
70
+ ezprinter.info(_NON_WINDOWS_MESSAGE)
71
+ return False
72
+
73
+
74
+ # The command modules register themselves on the groups above at import
75
+ # time; they must be imported after the groups exist.
76
+ from . import backup, inventory, registration # noqa: E402,F401
77
+
78
+ # ///////////////////////////////////////////////////////////////
79
+ # PUBLIC API
80
+ # ///////////////////////////////////////////////////////////////
81
+
82
+ __all__ = ["context_backup_group", "context_group"]
@@ -0,0 +1,344 @@
1
+ #!/usr/bin/env python3
2
+ # ///////////////////////////////////////////////////////////////
3
+ # CONTEXT BACKUP - Backup file commands
4
+ # Project: works-on-my-machine
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ """
8
+ Backup commands for the context menu.
9
+
10
+ Everything under this group addresses backup *files*. Names are resolved
11
+ inside the backup directory and never treated as paths: ``restore`` writes
12
+ to the Windows registry, so an unresolved name must stop before it.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ # ///////////////////////////////////////////////////////////////
18
+ # IMPORTS
19
+ # ///////////////////////////////////////////////////////////////
20
+ # Standard library imports
21
+ import sys
22
+ from datetime import datetime
23
+ from pathlib import Path
24
+
25
+ # Third-party imports
26
+ import click
27
+ from ezplog import LogLevel
28
+
29
+ # Local imports
30
+ from ....interfaces import ContextMenuInterface
31
+ from ....shared.results.context_results import (
32
+ BackupDataResult,
33
+ BackupFileInfo,
34
+ ContextCherryPickResult,
35
+ )
36
+ from ....ui.common import ezpl, ezprinter, ezwizard
37
+ from ....ui.context import ContextMenuUI
38
+ from ....ui.context.display import (
39
+ render_context_backup_content_result,
40
+ render_context_backup_list_result,
41
+ render_context_backup_result,
42
+ render_context_cherry_pick_result,
43
+ render_context_restore_result,
44
+ )
45
+ from . import _check_windows, context_backup_group
46
+
47
+ # ///////////////////////////////////////////////////////////////
48
+ # BACKUP CREATION
49
+ # ///////////////////////////////////////////////////////////////
50
+
51
+
52
+ @context_backup_group.command("create")
53
+ @click.help_option("-h", "--help")
54
+ @click.option(
55
+ "-o",
56
+ "--output",
57
+ help="Custom backup file path (default: auto-generated)",
58
+ )
59
+ @click.option(
60
+ "-v",
61
+ "--verbose",
62
+ is_flag=True,
63
+ help="Enable verbose output (DEBUG level)",
64
+ )
65
+ def context_backup_create(output: str | None, verbose: bool) -> None:
66
+ """💾 Create backup of current context menu entries."""
67
+ if verbose:
68
+ ezpl.set_level(LogLevel.DEBUG.label)
69
+
70
+ ezprinter.print_header("Context Menu Backup")
71
+
72
+ manager = ContextMenuInterface()
73
+
74
+ if not _check_windows(manager):
75
+ return
76
+
77
+ if output:
78
+ target_backup = output
79
+ else:
80
+ backup_dir = manager.get_backup_directory()
81
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
82
+ target_backup = str(backup_dir / f"context_menu_backup_{timestamp}.json")
83
+ ezprinter.info(f"Backup location: {target_backup}")
84
+
85
+ with ezwizard.spinner_with_status("Creating context menu backup...") as (
86
+ progress,
87
+ task,
88
+ ):
89
+ progress.update(task, status="Reading registry entries...")
90
+ result = manager.backup_entries(target_backup)
91
+
92
+ render_context_backup_result(result)
93
+ sys.exit(0 if result.success else 1)
94
+
95
+
96
+ # ///////////////////////////////////////////////////////////////
97
+ # BACKUP INSPECTION
98
+ # ///////////////////////////////////////////////////////////////
99
+
100
+
101
+ @context_backup_group.command("list")
102
+ @click.help_option("-h", "--help")
103
+ @click.option(
104
+ "-v",
105
+ "--verbose",
106
+ is_flag=True,
107
+ help="Enable verbose output (DEBUG level)",
108
+ )
109
+ def context_backup_list(verbose: bool) -> None:
110
+ """📋 List available context menu backup files."""
111
+ if verbose:
112
+ ezpl.set_level(LogLevel.DEBUG.label)
113
+
114
+ ezprinter.print_header("Context Menu Backups")
115
+
116
+ manager = ContextMenuInterface()
117
+
118
+ if not _check_windows(manager):
119
+ return
120
+
121
+ result = manager.list_backups()
122
+
123
+ render_context_backup_list_result(result)
124
+ sys.exit(0 if result.success else 1)
125
+
126
+
127
+ @context_backup_group.command("show")
128
+ @click.help_option("-h", "--help")
129
+ @click.argument("name")
130
+ @click.option(
131
+ "-v",
132
+ "--verbose",
133
+ is_flag=True,
134
+ help="Enable verbose output (DEBUG level)",
135
+ )
136
+ def context_backup_show(name: str, verbose: bool) -> None:
137
+ """🔍 Show the content of a context menu backup.
138
+
139
+ NAME is a bare backup file name, as listed by 'backup list'.
140
+ """
141
+ if verbose:
142
+ ezpl.set_level(LogLevel.DEBUG.label)
143
+
144
+ ezprinter.print_header("Context Menu Backup Content")
145
+
146
+ manager = ContextMenuInterface()
147
+
148
+ if not _check_windows(manager):
149
+ return
150
+
151
+ result = manager.read_backup(name)
152
+
153
+ render_context_backup_content_result(result)
154
+ sys.exit(0 if result.success else 1)
155
+
156
+
157
+ # ///////////////////////////////////////////////////////////////
158
+ # RESTORE
159
+ # ///////////////////////////////////////////////////////////////
160
+
161
+
162
+ def _describe_resolved_backup(
163
+ resolved: Path, content: BackupDataResult
164
+ ) -> BackupFileInfo:
165
+ """Describe an already resolved and readable backup file.
166
+
167
+ Built from the confined path and the parsed content only: the backup
168
+ listing is deliberately not consulted, so a readable backup whose name
169
+ falls outside the listing glob stays restorable.
170
+
171
+ Args:
172
+ resolved: Confined path returned by ``resolve_backup_path``.
173
+ content: Successful result returned by ``read_backup``.
174
+
175
+ Returns:
176
+ The metadata record expected by the restore confirmation prompt.
177
+ """
178
+ try:
179
+ stat = resolved.stat()
180
+ size_bytes = stat.st_size
181
+ modified_time = datetime.fromtimestamp(stat.st_mtime)
182
+ except OSError:
183
+ size_bytes = 0
184
+ modified_time = None
185
+
186
+ return BackupFileInfo(
187
+ filename=resolved.name,
188
+ filepath=str(resolved),
189
+ size_bytes=size_bytes,
190
+ modified_time=modified_time,
191
+ entry_count=(content.metadata or {}).get("total_entries", 0),
192
+ )
193
+
194
+
195
+ @context_backup_group.command("restore")
196
+ @click.help_option("-h", "--help")
197
+ @click.argument("name", required=False)
198
+ @click.option(
199
+ "-v",
200
+ "--verbose",
201
+ is_flag=True,
202
+ help="Enable verbose output (DEBUG level)",
203
+ )
204
+ def context_backup_restore(name: str | None, verbose: bool) -> None:
205
+ """🔄 Restore context menu entries from a backup.
206
+
207
+ NAME is a bare backup file name, as listed by 'backup list'. Without
208
+ NAME, a backup is chosen interactively.
209
+ """
210
+ if verbose:
211
+ ezpl.set_level(LogLevel.DEBUG.label)
212
+
213
+ ezprinter.print_header("Context Menu Restore")
214
+
215
+ manager = ContextMenuInterface()
216
+
217
+ if not _check_windows(manager):
218
+ return
219
+
220
+ if name:
221
+ content = manager.read_backup(name)
222
+ if not content.success:
223
+ ezprinter.error(str(content.error))
224
+ ezprinter.info("Run 'womm context backup list' to see available names")
225
+ sys.exit(1)
226
+
227
+ resolved = manager.resolve_backup_path(name)
228
+ if resolved is None:
229
+ ezprinter.error(f"No readable backup named {name!r}")
230
+ ezprinter.info("Run 'womm context backup list' to see available names")
231
+ sys.exit(1)
232
+
233
+ selected = _describe_resolved_backup(resolved, content)
234
+ target = str(resolved)
235
+ else:
236
+ listing = manager.list_backups()
237
+ if not listing.success:
238
+ ezprinter.error(f"Could not list backups: {listing.error}")
239
+ sys.exit(1)
240
+
241
+ selected = ContextMenuUI.show_backup_selection_menu(listing.backups or [])
242
+ if selected is None:
243
+ ezprinter.info("Restore cancelled")
244
+ return
245
+ target = selected.filepath
246
+
247
+ if not ContextMenuUI.confirm_restore_operation(selected):
248
+ ezprinter.info("Restore cancelled")
249
+ return
250
+
251
+ with ezwizard.spinner_with_status("Restoring context menu from backup...") as (
252
+ progress,
253
+ task,
254
+ ):
255
+ progress.update(task, status="Restoring from backup...")
256
+ result = manager.restore_entries(target)
257
+
258
+ render_context_restore_result(result)
259
+ sys.exit(0 if result.success else 1)
260
+
261
+
262
+ # ///////////////////////////////////////////////////////////////
263
+ # CHERRY-PICK COMMANDS
264
+ # ///////////////////////////////////////////////////////////////
265
+
266
+
267
+ @context_backup_group.command("cherry-pick")
268
+ @click.help_option("-h", "--help")
269
+ @click.option(
270
+ "-v",
271
+ "--verbose",
272
+ is_flag=True,
273
+ help="Enable verbose output (DEBUG level)",
274
+ )
275
+ def context_cherry_pick(verbose: bool) -> None:
276
+ """🍒 Cherry-pick specific context menu entries from backups."""
277
+ if verbose:
278
+ ezpl.set_level(LogLevel.DEBUG.label)
279
+
280
+ ezprinter.print_header("Context Menu Cherry-Pick")
281
+
282
+ manager = ContextMenuInterface()
283
+
284
+ if not _check_windows(manager):
285
+ return
286
+
287
+ backup_dir = manager.get_backup_directory()
288
+ if not backup_dir.exists():
289
+ ezprinter.error("No backup directory found")
290
+ ezprinter.info("Create a backup first using 'womm context backup create'")
291
+ sys.exit(1)
292
+
293
+ with ezwizard.spinner_with_status("Scanning backup files...") as (
294
+ progress,
295
+ task,
296
+ ):
297
+ progress.update(task, status="Collecting context menu entries...")
298
+ all_entries = manager.collect_entries_from_backups()
299
+
300
+ if not all_entries:
301
+ ezprinter.error("No context menu entries found in backups")
302
+ sys.exit(1)
303
+
304
+ current_keys = manager.get_current_entry_keys()
305
+ available_entries = manager.filter_available_entries(all_entries, current_keys)
306
+
307
+ if not available_entries:
308
+ ezprinter.info("All context menu entries from backups are already installed")
309
+ result = ContextCherryPickResult(success=True, message="already_installed")
310
+ render_context_cherry_pick_result(result)
311
+ return
312
+
313
+ selected_entries = ContextMenuUI.show_cherry_pick_menu(available_entries)
314
+ if not selected_entries:
315
+ ezprinter.info("Cherry-pick cancelled")
316
+ return
317
+
318
+ with ezwizard.spinner_with_status(
319
+ f"Applying {len(selected_entries)} selected entries..."
320
+ ) as (progress, task):
321
+ results = manager.apply_cherry_picked_entries(selected_entries)
322
+
323
+ success_count = sum(1 for success in results.values() if success)
324
+ result = ContextCherryPickResult(
325
+ success=success_count == len(selected_entries),
326
+ success_count=success_count,
327
+ total_selected=len(selected_entries),
328
+ selected_entries=list(results.keys()),
329
+ )
330
+ render_context_cherry_pick_result(result)
331
+ sys.exit(0 if result.success else 1)
332
+
333
+
334
+ # ///////////////////////////////////////////////////////////////
335
+ # PUBLIC API
336
+ # ///////////////////////////////////////////////////////////////
337
+
338
+ __all__ = [
339
+ "context_backup_create",
340
+ "context_backup_list",
341
+ "context_backup_restore",
342
+ "context_backup_show",
343
+ "context_cherry_pick",
344
+ ]
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env python3
2
+ # ///////////////////////////////////////////////////////////////
3
+ # CONTEXT INVENTORY - Listing and quick setup commands
4
+ # Project: works-on-my-machine
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ """
8
+ Live-state commands for the context menu.
9
+
10
+ ``list`` shows the registry's live entries, summary first. The former
11
+ ``status`` command was a projection of this listing and no longer exists.
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 ....ui.common import ezpl, ezprinter, ezwizard
29
+ from ....ui.context.display import (
30
+ render_context_entries_result,
31
+ render_context_setup_result,
32
+ )
33
+ from . import _check_windows, context_group
34
+
35
+ # ///////////////////////////////////////////////////////////////
36
+ # LISTING COMMANDS
37
+ # ///////////////////////////////////////////////////////////////
38
+
39
+
40
+ @context_group.command("list")
41
+ @click.help_option("-h", "--help")
42
+ @click.option(
43
+ "-v",
44
+ "--verbose",
45
+ is_flag=True,
46
+ help="Enable verbose output (DEBUG level)",
47
+ )
48
+ def context_list(verbose: bool) -> None:
49
+ """📋 List registered context menu entries."""
50
+ if verbose:
51
+ ezpl.set_level(LogLevel.DEBUG.label)
52
+
53
+ ezprinter.print_header("Context Menu List")
54
+
55
+ manager = ContextMenuInterface()
56
+
57
+ if not _check_windows(manager):
58
+ return
59
+
60
+ with ezwizard.spinner_with_status("Retrieving context menu entries...") as (
61
+ progress,
62
+ task,
63
+ ):
64
+ progress.update(task, status="Reading registry entries...")
65
+ result = manager.list_entries()
66
+
67
+ render_context_entries_result(result)
68
+ sys.exit(0 if result.success else 1)
69
+
70
+
71
+ # ///////////////////////////////////////////////////////////////
72
+ # QUICK SETUP COMMANDS
73
+ # ///////////////////////////////////////////////////////////////
74
+
75
+
76
+ @context_group.command("quick-setup")
77
+ @click.help_option("-h", "--help")
78
+ @click.option(
79
+ "-v",
80
+ "--verbose",
81
+ is_flag=True,
82
+ help="Enable verbose output (DEBUG level)",
83
+ )
84
+ def context_quick_setup(verbose: bool) -> None:
85
+ """⚡ Quick setup common WOMM tools in context menu."""
86
+ if verbose:
87
+ ezpl.set_level(LogLevel.DEBUG.label)
88
+
89
+ ezprinter.print_header("Context Menu Quick Setup")
90
+
91
+ manager = ContextMenuInterface()
92
+
93
+ if not _check_windows(manager):
94
+ return
95
+
96
+ with ezwizard.spinner_with_status("Setting up common WOMM tools...") as (
97
+ progress,
98
+ task,
99
+ ):
100
+ progress.update(task, status="Registering WOMM tools...")
101
+ result = manager.quick_setup_tools(verbose)
102
+
103
+ render_context_setup_result(result)
104
+ sys.exit(0 if result.success else 1)
105
+
106
+
107
+ # ///////////////////////////////////////////////////////////////
108
+ # PUBLIC API
109
+ # ///////////////////////////////////////////////////////////////
110
+
111
+ __all__ = ["context_list", "context_quick_setup"]