|
8 | 8 | from typing import Any, Callable |
9 | 9 |
|
10 | 10 | from .contracts import EXIT_PRECHECK_FAILED, EXIT_WORKSPACE_INVALID |
| 11 | +from .headless_commands import run_workspace_apply |
11 | 12 | from .output import plain |
| 13 | +from .workspace_apply_args import build_workspace_apply_args |
12 | 14 |
|
13 | 15 |
|
14 | 16 | def register_workspace_commands( |
@@ -85,6 +87,84 @@ def workspace_files(path, as_json): |
85 | 87 | for item in result["python_files_preview"]: |
86 | 88 | plain(f" - {item}") |
87 | 89 |
|
| 90 | + @workspace.command("apply") |
| 91 | + @click.argument("path", required=False, type=click.Path(exists=False)) |
| 92 | + @click.option("--json", "as_json", is_flag=True) |
| 93 | + @click.option("--with-venv", is_flag=True, help="Create or reuse a local workspace venv") |
| 94 | + @click.option("--entrypoint", type=str, help="Override detected entrypoint") |
| 95 | + @click.option("--no-auto-config", is_flag=True, help="Skip auto configuration pass") |
| 96 | + @click.option("--no-inspect-files", is_flag=True, help="Skip recursive python file scan") |
| 97 | + @click.option("--no-apply-venv-pref", is_flag=True, help="Skip workspace venv preference application") |
| 98 | + @click.option("--no-apply-engine-configs", is_flag=True, help="Skip loading workspace engine configs") |
| 99 | + @click.option("--strict", is_flag=True, help="Fail when required checks are missing") |
| 100 | + @click.option("--require-entrypoint", is_flag=True, help="Require a resolved entrypoint") |
| 101 | + def workspace_apply( |
| 102 | + path, |
| 103 | + as_json, |
| 104 | + with_venv, |
| 105 | + entrypoint, |
| 106 | + no_auto_config, |
| 107 | + no_inspect_files, |
| 108 | + no_apply_venv_pref, |
| 109 | + no_apply_engine_configs, |
| 110 | + strict, |
| 111 | + require_entrypoint, |
| 112 | + ): |
| 113 | + args = build_workspace_apply_args( |
| 114 | + path=path, |
| 115 | + as_json=bool(as_json), |
| 116 | + with_venv=bool(with_venv), |
| 117 | + entrypoint=entrypoint, |
| 118 | + no_auto_config=bool(no_auto_config), |
| 119 | + no_inspect_files=bool(no_inspect_files), |
| 120 | + no_apply_venv_pref=bool(no_apply_venv_pref), |
| 121 | + no_apply_engine_configs=bool(no_apply_engine_configs), |
| 122 | + strict=bool(strict), |
| 123 | + require_entrypoint=bool(require_entrypoint), |
| 124 | + ) |
| 125 | + code = run_workspace_apply(args) |
| 126 | + if code: |
| 127 | + raise click.exceptions.Exit(code) |
| 128 | + |
| 129 | + @workspace.command("select") |
| 130 | + @click.argument("path", required=False, type=click.Path(exists=False)) |
| 131 | + @click.option("--json", "as_json", is_flag=True) |
| 132 | + @click.option("--with-venv", is_flag=True, help="Create or reuse a local workspace venv") |
| 133 | + @click.option("--entrypoint", type=str, help="Override detected entrypoint") |
| 134 | + @click.option("--no-auto-config", is_flag=True, help="Skip auto configuration pass") |
| 135 | + @click.option("--no-inspect-files", is_flag=True, help="Skip recursive python file scan") |
| 136 | + @click.option("--no-apply-venv-pref", is_flag=True, help="Skip workspace venv preference application") |
| 137 | + @click.option("--no-apply-engine-configs", is_flag=True, help="Skip loading workspace engine configs") |
| 138 | + @click.option("--strict", is_flag=True, help="Fail when required checks are missing") |
| 139 | + @click.option("--require-entrypoint", is_flag=True, help="Require a resolved entrypoint") |
| 140 | + def workspace_select( |
| 141 | + path, |
| 142 | + as_json, |
| 143 | + with_venv, |
| 144 | + entrypoint, |
| 145 | + no_auto_config, |
| 146 | + no_inspect_files, |
| 147 | + no_apply_venv_pref, |
| 148 | + no_apply_engine_configs, |
| 149 | + strict, |
| 150 | + require_entrypoint, |
| 151 | + ): |
| 152 | + args = build_workspace_apply_args( |
| 153 | + path=path, |
| 154 | + as_json=bool(as_json), |
| 155 | + with_venv=bool(with_venv), |
| 156 | + entrypoint=entrypoint, |
| 157 | + no_auto_config=bool(no_auto_config), |
| 158 | + no_inspect_files=bool(no_inspect_files), |
| 159 | + no_apply_venv_pref=bool(no_apply_venv_pref), |
| 160 | + no_apply_engine_configs=bool(no_apply_engine_configs), |
| 161 | + strict=bool(strict), |
| 162 | + require_entrypoint=bool(require_entrypoint), |
| 163 | + ) |
| 164 | + code = run_workspace_apply(args) |
| 165 | + if code: |
| 166 | + raise click.exceptions.Exit(code) |
| 167 | + |
88 | 168 | @cli.command("init") |
89 | 169 | @click.argument("workspace", required=False, type=click.Path(exists=False)) |
90 | 170 | @click.option("--json", "as_json", is_flag=True) |
@@ -140,3 +220,81 @@ def ws_config_auto_cmd(workspace, entrypoint, as_json): |
140 | 220 | entrypoint=entrypoint, |
141 | 221 | as_json=as_json, |
142 | 222 | ) |
| 223 | + |
| 224 | + @ws.command("apply") |
| 225 | + @click.argument("workspace", required=False, type=click.Path(exists=False)) |
| 226 | + @click.option("--json", "as_json", is_flag=True) |
| 227 | + @click.option("--with-venv", is_flag=True, help="Create or reuse a local workspace venv") |
| 228 | + @click.option("--entrypoint", type=str, help="Override detected entrypoint") |
| 229 | + @click.option("--no-auto-config", is_flag=True, help="Skip auto configuration pass") |
| 230 | + @click.option("--no-inspect-files", is_flag=True, help="Skip recursive python file scan") |
| 231 | + @click.option("--no-apply-venv-pref", is_flag=True, help="Skip workspace venv preference application") |
| 232 | + @click.option("--no-apply-engine-configs", is_flag=True, help="Skip loading workspace engine configs") |
| 233 | + @click.option("--strict", is_flag=True, help="Fail when required checks are missing") |
| 234 | + @click.option("--require-entrypoint", is_flag=True, help="Require a resolved entrypoint") |
| 235 | + def ws_apply_cmd( |
| 236 | + workspace, |
| 237 | + as_json, |
| 238 | + with_venv, |
| 239 | + entrypoint, |
| 240 | + no_auto_config, |
| 241 | + no_inspect_files, |
| 242 | + no_apply_venv_pref, |
| 243 | + no_apply_engine_configs, |
| 244 | + strict, |
| 245 | + require_entrypoint, |
| 246 | + ): |
| 247 | + args = build_workspace_apply_args( |
| 248 | + path=workspace, |
| 249 | + as_json=bool(as_json), |
| 250 | + with_venv=bool(with_venv), |
| 251 | + entrypoint=entrypoint, |
| 252 | + no_auto_config=bool(no_auto_config), |
| 253 | + no_inspect_files=bool(no_inspect_files), |
| 254 | + no_apply_venv_pref=bool(no_apply_venv_pref), |
| 255 | + no_apply_engine_configs=bool(no_apply_engine_configs), |
| 256 | + strict=bool(strict), |
| 257 | + require_entrypoint=bool(require_entrypoint), |
| 258 | + ) |
| 259 | + code = run_workspace_apply(args) |
| 260 | + if code: |
| 261 | + raise click.exceptions.Exit(code) |
| 262 | + |
| 263 | + @ws.command("select") |
| 264 | + @click.argument("workspace", required=False, type=click.Path(exists=False)) |
| 265 | + @click.option("--json", "as_json", is_flag=True) |
| 266 | + @click.option("--with-venv", is_flag=True, help="Create or reuse a local workspace venv") |
| 267 | + @click.option("--entrypoint", type=str, help="Override detected entrypoint") |
| 268 | + @click.option("--no-auto-config", is_flag=True, help="Skip auto configuration pass") |
| 269 | + @click.option("--no-inspect-files", is_flag=True, help="Skip recursive python file scan") |
| 270 | + @click.option("--no-apply-venv-pref", is_flag=True, help="Skip workspace venv preference application") |
| 271 | + @click.option("--no-apply-engine-configs", is_flag=True, help="Skip loading workspace engine configs") |
| 272 | + @click.option("--strict", is_flag=True, help="Fail when required checks are missing") |
| 273 | + @click.option("--require-entrypoint", is_flag=True, help="Require a resolved entrypoint") |
| 274 | + def ws_select_cmd( |
| 275 | + workspace, |
| 276 | + as_json, |
| 277 | + with_venv, |
| 278 | + entrypoint, |
| 279 | + no_auto_config, |
| 280 | + no_inspect_files, |
| 281 | + no_apply_venv_pref, |
| 282 | + no_apply_engine_configs, |
| 283 | + strict, |
| 284 | + require_entrypoint, |
| 285 | + ): |
| 286 | + args = build_workspace_apply_args( |
| 287 | + path=workspace, |
| 288 | + as_json=bool(as_json), |
| 289 | + with_venv=bool(with_venv), |
| 290 | + entrypoint=entrypoint, |
| 291 | + no_auto_config=bool(no_auto_config), |
| 292 | + no_inspect_files=bool(no_inspect_files), |
| 293 | + no_apply_venv_pref=bool(no_apply_venv_pref), |
| 294 | + no_apply_engine_configs=bool(no_apply_engine_configs), |
| 295 | + strict=bool(strict), |
| 296 | + require_entrypoint=bool(require_entrypoint), |
| 297 | + ) |
| 298 | + code = run_workspace_apply(args) |
| 299 | + if code: |
| 300 | + raise click.exceptions.Exit(code) |
0 commit comments