webcompy-cli 0.0.14__tar.gz

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 (48) hide show
  1. webcompy_cli-0.0.14/.gitignore +167 -0
  2. webcompy_cli-0.0.14/LICENSE +21 -0
  3. webcompy_cli-0.0.14/PKG-INFO +53 -0
  4. webcompy_cli-0.0.14/README.md +25 -0
  5. webcompy_cli-0.0.14/pyproject.toml +42 -0
  6. webcompy_cli-0.0.14/src/webcompy_cli/__init__.py +20 -0
  7. webcompy_cli-0.0.14/src/webcompy_cli/_argparser.py +232 -0
  8. webcompy_cli-0.0.14/src/webcompy_cli/_browser_probes.py +648 -0
  9. webcompy_cli-0.0.14/src/webcompy_cli/_browser_test_harness.py +554 -0
  10. webcompy_cli-0.0.14/src/webcompy_cli/_build.py +425 -0
  11. webcompy_cli-0.0.14/src/webcompy_cli/_console_types.py +15 -0
  12. webcompy_cli-0.0.14/src/webcompy_cli/_dependency_resolver.py +301 -0
  13. webcompy_cli-0.0.14/src/webcompy_cli/_dualrun_pytest_plugin.py +130 -0
  14. webcompy_cli-0.0.14/src/webcompy_cli/_exception.py +9 -0
  15. webcompy_cli-0.0.14/src/webcompy_cli/_generate.py +224 -0
  16. webcompy_cli-0.0.14/src/webcompy_cli/_init_project.py +54 -0
  17. webcompy_cli-0.0.14/src/webcompy_cli/_inspect.py +741 -0
  18. webcompy_cli-0.0.14/src/webcompy_cli/_inspect_pyexec.py +244 -0
  19. webcompy_cli-0.0.14/src/webcompy_cli/_lock.py +82 -0
  20. webcompy_cli-0.0.14/src/webcompy_cli/_lockfile.py +396 -0
  21. webcompy_cli-0.0.14/src/webcompy_cli/_lockfile_sync.py +343 -0
  22. webcompy_cli-0.0.14/src/webcompy_cli/_output.py +150 -0
  23. webcompy_cli-0.0.14/src/webcompy_cli/_prebuild.py +661 -0
  24. webcompy_cli-0.0.14/src/webcompy_cli/_pwa.py +474 -0
  25. webcompy_cli-0.0.14/src/webcompy_cli/_pyodide_downloader.py +113 -0
  26. webcompy_cli-0.0.14/src/webcompy_cli/_pyodide_lock.py +74 -0
  27. webcompy_cli-0.0.14/src/webcompy_cli/_runtime_downloader.py +222 -0
  28. webcompy_cli-0.0.14/src/webcompy_cli/_server.py +568 -0
  29. webcompy_cli-0.0.14/src/webcompy_cli/_static_files.py +27 -0
  30. webcompy_cli-0.0.14/src/webcompy_cli/_utils.py +72 -0
  31. webcompy_cli-0.0.14/src/webcompy_cli/_version_sweep.py +213 -0
  32. webcompy_cli-0.0.14/src/webcompy_cli/_wheel_builder.py +509 -0
  33. webcompy_cli-0.0.14/src/webcompy_cli/config/__init__.py +23 -0
  34. webcompy_cli-0.0.14/src/webcompy_cli/config/_build_config.py +168 -0
  35. webcompy_cli-0.0.14/src/webcompy_cli/config/_pwa_config.py +203 -0
  36. webcompy_cli-0.0.14/src/webcompy_cli/config/_server_config.py +53 -0
  37. webcompy_cli-0.0.14/src/webcompy_cli/py.typed +0 -0
  38. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/__init__.py +0 -0
  39. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/app.py +22 -0
  40. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/components/__init__.py +0 -0
  41. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/components/fizzbuzz.py +117 -0
  42. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/components/home.py +15 -0
  43. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/components/input.py +34 -0
  44. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/components/navigation.py +36 -0
  45. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/components/not_found.py +22 -0
  46. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/components/root.py +16 -0
  47. webcompy_cli-0.0.14/src/webcompy_cli/template_data/app/router.py +17 -0
  48. webcompy_cli-0.0.14/src/webcompy_cli/template_data/webcompy_config.py +12 -0
@@ -0,0 +1,167 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ parts/
18
+ sdist/
19
+ var/
20
+ wheels/
21
+ share/python-wheels/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+ MANIFEST
26
+
27
+ # PyInstaller
28
+ # Usually these files are written by a python script from a template
29
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ *.py,cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+ cover/
51
+
52
+ # Translations
53
+ *.mo
54
+ *.pot
55
+
56
+ # Django stuff:
57
+ *.log
58
+ local_settings.py
59
+ db.sqlite3
60
+ db.sqlite3-journal
61
+
62
+ # Flask stuff:
63
+ instance/
64
+ .webassets-cache
65
+
66
+ # Scrapy stuff:
67
+ .scrapy
68
+
69
+ # PyBuilder
70
+ .pybuilder/
71
+ target/
72
+
73
+ # Jupyter Notebook
74
+ .ipynb_checkpoints
75
+
76
+ # IPython
77
+ profile_default/
78
+ ipython_config.py
79
+
80
+ # uv
81
+ .venv/
82
+
83
+ # pipenv
84
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
85
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
86
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
87
+ # install all needed dependencies.
88
+ Pipfile.lock
89
+
90
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
91
+ __pypackages__/
92
+
93
+ # Celery stuff
94
+ celerybeat-schedule
95
+ celerybeat.pid
96
+
97
+ # SageMath parsed files
98
+ *.sage.py
99
+
100
+ # Environments
101
+ .env
102
+ .venv
103
+ env/
104
+ venv/
105
+ ENV/
106
+ env.bak/
107
+ venv.bak/
108
+
109
+ # Spyder project settings
110
+ .spyderproject
111
+ .spyproject
112
+
113
+ # Rope project settings
114
+ .ropeproject
115
+
116
+ # mkdocs documentation
117
+ /site
118
+
119
+ # mypy
120
+ .mypy_cache/
121
+ .dmypy.json
122
+ dmypy.json
123
+
124
+ # Pyre type checker
125
+ .pyre/
126
+
127
+ # pytype static type analyzer
128
+ .pytype/
129
+
130
+ # Cython debug symbols
131
+ cython_debug/
132
+
133
+ # AI coding harness local config
134
+ /opencode.json
135
+ /opencode.jsonc
136
+ /CLAUDE.local.md
137
+ /.claude/settings.local.json
138
+ /.agents/*.local.json
139
+
140
+ # Temporary directory
141
+ **/.tmp/
142
+
143
+ # Generated docs site
144
+ /docs/
145
+ docs_app/dist/
146
+
147
+ # E2E test server log
148
+ .e2e-server.log
149
+
150
+ # WebComPy lock files
151
+ webcompy-lock.json
152
+
153
+ # Playwright MCP
154
+ .playwright-mcp/
155
+
156
+ # Workspace directory for development artifacts
157
+ .workspace/
158
+
159
+ # Browser test screenshots and recordings (root only, allow in static/)
160
+ /*.png
161
+ /*.jpg
162
+ /*.jpeg
163
+ /*.gif
164
+
165
+
166
+ # Dual-run / sweep artifacts
167
+ /artifacts/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Kento NIWASE
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.5
2
+ Name: webcompy-cli
3
+ Version: 0.0.14
4
+ Summary: WebComPy CLI tools (dev server, SSG, project init)
5
+ Project-URL: Homepage, https://github.com/kniwase/WebComPy
6
+ Project-URL: Documentation, https://webcompy.net/documents/
7
+ Project-URL: LLM Docs, https://webcompy.net/llms.txt
8
+ Author-email: Kento Niwase <kento.niwase@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: browser,cli,framework,frontend
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Requires-Python: >=3.12
17
+ Requires-Dist: aiofiles
18
+ Requires-Dist: sse-starlette
19
+ Requires-Dist: starlette
20
+ Requires-Dist: uvicorn
21
+ Requires-Dist: webcompy-server==0.0.14
22
+ Requires-Dist: webcompy==0.0.14
23
+ Provides-Extra: inspect
24
+ Requires-Dist: playwright; extra == 'inspect'
25
+ Provides-Extra: lock
26
+ Requires-Dist: packaging; extra == 'lock'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # webcompy-cli
30
+
31
+ Command-line tooling, development/production ASGI server, build-once prebuild pipeline, static site generator, and browser inspection CLI for [WebComPy](https://github.com/kniwase/WebComPy).
32
+
33
+ Invoke via `python -m webcompy <command>`:
34
+
35
+ - `init` — Scaffold a new WebComPy project
36
+ - `lock` — Resolve and synchronize browser dependencies (`webcompy-lock.json`)
37
+ - `start` — Run the development (`--dev`), production, or prebuilt (`--prebuilt`) server
38
+ - `prebuild` — Materialize deployable bundles, wheels, and prerendered HTML once (`PrebuildManifest`)
39
+ - `generate` — Export a complete static site (SSG) with wheels, assets, and optional PWA service worker
40
+ - `inspect` — Headless Playwright inspection (`serve`, `screenshot`, `console`, `query`, `click`, `navigate`, `verify`, `pyexec`) — install with `webcompy-cli[inspect]`
41
+
42
+ This distribution is versioned in lockstep with `webcompy` and `webcompy-server`.
43
+
44
+ ## Documentation & Resources
45
+
46
+ - [Documentation](https://webcompy.net/documents/)
47
+ - [CLI Reference](https://webcompy.net/documents/server/cli-reference/)
48
+ - [LLM Documentation Index (`llms.txt`)](https://webcompy.net/llms.txt) — bundles: [`llms-small.txt`](https://webcompy.net/llms-small.txt) / [`llms-full.txt`](https://webcompy.net/llms-full.txt)
49
+ - [Source Code & Discussions](https://github.com/kniwase/WebComPy)
50
+
51
+ ## License
52
+
53
+ MIT License — see [LICENSE](LICENSE).
@@ -0,0 +1,25 @@
1
+ # webcompy-cli
2
+
3
+ Command-line tooling, development/production ASGI server, build-once prebuild pipeline, static site generator, and browser inspection CLI for [WebComPy](https://github.com/kniwase/WebComPy).
4
+
5
+ Invoke via `python -m webcompy <command>`:
6
+
7
+ - `init` — Scaffold a new WebComPy project
8
+ - `lock` — Resolve and synchronize browser dependencies (`webcompy-lock.json`)
9
+ - `start` — Run the development (`--dev`), production, or prebuilt (`--prebuilt`) server
10
+ - `prebuild` — Materialize deployable bundles, wheels, and prerendered HTML once (`PrebuildManifest`)
11
+ - `generate` — Export a complete static site (SSG) with wheels, assets, and optional PWA service worker
12
+ - `inspect` — Headless Playwright inspection (`serve`, `screenshot`, `console`, `query`, `click`, `navigate`, `verify`, `pyexec`) — install with `webcompy-cli[inspect]`
13
+
14
+ This distribution is versioned in lockstep with `webcompy` and `webcompy-server`.
15
+
16
+ ## Documentation & Resources
17
+
18
+ - [Documentation](https://webcompy.net/documents/)
19
+ - [CLI Reference](https://webcompy.net/documents/server/cli-reference/)
20
+ - [LLM Documentation Index (`llms.txt`)](https://webcompy.net/llms.txt) — bundles: [`llms-small.txt`](https://webcompy.net/llms-small.txt) / [`llms-full.txt`](https://webcompy.net/llms-full.txt)
21
+ - [Source Code & Discussions](https://github.com/kniwase/WebComPy)
22
+
23
+ ## License
24
+
25
+ MIT License — see [LICENSE](LICENSE).
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "webcompy-cli"
7
+ version = "0.0.14"
8
+ description = "WebComPy CLI tools (dev server, SSG, project init)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.12"
13
+ authors = [
14
+ { name = "Kento Niwase", email = "kento.niwase@gmail.com" },
15
+ ]
16
+ keywords = ["browser", "frontend", "framework", "cli"]
17
+ classifiers = [
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Operating System :: OS Independent",
22
+ ]
23
+ dependencies = [
24
+ "webcompy==0.0.14",
25
+ "webcompy-server==0.0.14",
26
+ "starlette",
27
+ "uvicorn",
28
+ "sse-starlette",
29
+ "aiofiles",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ inspect = ["playwright"]
34
+ lock = ["packaging"]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/kniwase/WebComPy"
38
+ Documentation = "https://webcompy.net/documents/"
39
+ "LLM Docs" = "https://webcompy.net/llms.txt"
40
+
41
+ [tool.hatch.build.targets.wheel]
42
+ packages = ["src/webcompy_cli"]
@@ -0,0 +1,20 @@
1
+ """Public entry points for the ``webcompy_cli`` package.
2
+
3
+ LLM-friendly documentation is published at https://webcompy.net/llms.txt
4
+ (compact: https://webcompy.net/llms-small.txt, full: https://webcompy.net/llms-full.txt).
5
+ """
6
+
7
+ from webcompy_cli._generate import generate_static_site
8
+ from webcompy_cli._inspect import run_inspect
9
+ from webcompy_cli._prebuild import prebuild_app
10
+ from webcompy_cli._server import create_asgi_app, run_server
11
+ from webcompy_cli._utils import discover_config
12
+
13
+ __all__ = [
14
+ "create_asgi_app",
15
+ "discover_config",
16
+ "generate_static_site",
17
+ "prebuild_app",
18
+ "run_inspect",
19
+ "run_server",
20
+ ]
@@ -0,0 +1,232 @@
1
+ """Command-line argument parsing for the ``webcompy`` CLI."""
2
+
3
+ import sys
4
+ from argparse import ArgumentParser
5
+ from typing import Any, Literal
6
+
7
+
8
+ def _add_shared_build_args(parser: ArgumentParser) -> None:
9
+ parser.add_argument(
10
+ "--config",
11
+ type=str,
12
+ help="Python import path for config module (e.g., my_project.webcompy_config)",
13
+ )
14
+ serve_all_deps_flags = parser.add_mutually_exclusive_group()
15
+ serve_all_deps_flags.add_argument(
16
+ "--serve-all-deps",
17
+ action="store_true",
18
+ default=None,
19
+ dest="serve_all_deps",
20
+ help="bundle all pure-Python deps into app wheel (default)",
21
+ )
22
+ serve_all_deps_flags.add_argument(
23
+ "--no-serve-all-deps",
24
+ action="store_false",
25
+ dest="serve_all_deps",
26
+ help="load CDN-available pure-Python deps from Pyodide CDN",
27
+ )
28
+ parser.add_argument(
29
+ "--wasm-serving",
30
+ choices=["cdn", "local"],
31
+ default=None,
32
+ help="WASM package serving mode: 'cdn' (default) or 'local'",
33
+ )
34
+ parser.add_argument(
35
+ "--runtime-serving",
36
+ choices=["cdn", "local"],
37
+ default=None,
38
+ help="PyScript/Pyodide runtime serving mode: 'cdn' (default) or 'local'",
39
+ )
40
+ standalone_flags = parser.add_mutually_exclusive_group()
41
+ standalone_flags.add_argument(
42
+ "--standalone",
43
+ action="store_true",
44
+ default=None,
45
+ dest="standalone",
46
+ help="enable standalone mode (all assets served locally)",
47
+ )
48
+ standalone_flags.add_argument(
49
+ "--no-standalone",
50
+ action="store_false",
51
+ dest="standalone",
52
+ help="disable standalone mode (default)",
53
+ )
54
+ parser.add_argument(
55
+ "--wheel-mode",
56
+ choices=["bundled", "split"],
57
+ default=None,
58
+ help="wheel bundling mode: 'bundled' (default) or 'split'",
59
+ )
60
+
61
+
62
+ def get_params() -> tuple[Literal["start", "generate", "prebuild", "init", "lock", "inspect"], dict[str, Any]]:
63
+ def _command(subcommand_name: str):
64
+ return lambda: subcommand_name
65
+
66
+ maincommand = "python -m webcompy"
67
+ parser = ArgumentParser(
68
+ prog=maincommand,
69
+ add_help=True,
70
+ epilog="Documentation: https://webcompy.net/documents/ | LLM docs: https://webcompy.net/llms.txt",
71
+ )
72
+ subparsers = parser.add_subparsers()
73
+
74
+ # start
75
+ subcommand_name = "start"
76
+ parser_start = subparsers.add_parser(
77
+ subcommand_name,
78
+ help=f"Starts HTTP server. See `{maincommand} {subcommand_name} --help` for options.",
79
+ )
80
+ parser_start.add_argument(
81
+ "--dev",
82
+ action="store_true",
83
+ help="launch dev server with hot-reload",
84
+ )
85
+ parser_start.add_argument(
86
+ "--port",
87
+ type=int,
88
+ help="server port",
89
+ )
90
+ parser_start.add_argument(
91
+ "--prebuilt",
92
+ nargs="?",
93
+ const="",
94
+ default=None,
95
+ metavar="DIR",
96
+ help="serve from prebuilt artifacts without build-time resolution",
97
+ )
98
+ parser_start.add_argument(
99
+ "--no-serve-assets",
100
+ action="store_true",
101
+ help="disable serving framework assets and static files (for CDN / asset offloading)",
102
+ )
103
+ _add_shared_build_args(parser_start)
104
+ parser_start.set_defaults(__command_getter__=_command(subcommand_name))
105
+
106
+ # generate
107
+ subcommand_name = "generate"
108
+ parser_generate = subparsers.add_parser(
109
+ subcommand_name,
110
+ help=f"Generates static html files. See `{maincommand} {subcommand_name} --help` for options.",
111
+ )
112
+ parser_generate.add_argument(
113
+ "--dist",
114
+ type=str,
115
+ help="dist dir",
116
+ )
117
+ _add_shared_build_args(parser_generate)
118
+ parser_generate.set_defaults(__command_getter__=_command(subcommand_name))
119
+
120
+ # prebuild
121
+ subcommand_name = "prebuild"
122
+ parser_prebuild = subparsers.add_parser(
123
+ subcommand_name,
124
+ help=f"Materializes deployable prebuilt artifacts. See `{maincommand} {subcommand_name} --help` for options.",
125
+ )
126
+ parser_prebuild.add_argument(
127
+ "--out",
128
+ type=str,
129
+ default=None,
130
+ help="prebuild output directory (relative to CWD)",
131
+ )
132
+ parser_prebuild.add_argument(
133
+ "--prerender",
134
+ choices=["none", "static", "all"],
135
+ default=None,
136
+ help="prerender depth policy: 'none', 'static', or 'all'",
137
+ )
138
+ parser_prebuild.add_argument(
139
+ "--emit-python",
140
+ type=str,
141
+ default=None,
142
+ help="emit standalone Python module defining PREBUILD: PrebuildManifest",
143
+ )
144
+ embed_flags = parser_prebuild.add_mutually_exclusive_group()
145
+ embed_flags.add_argument(
146
+ "--embed-resources",
147
+ action="store_true",
148
+ default=None,
149
+ dest="embed_resources",
150
+ help="embed allow-listed resources into --emit-python output (default)",
151
+ )
152
+ embed_flags.add_argument(
153
+ "--no-embed-resources",
154
+ action="store_false",
155
+ dest="embed_resources",
156
+ help="omit in-memory resource bytes from --emit-python output",
157
+ )
158
+ _add_shared_build_args(parser_prebuild)
159
+ parser_prebuild.set_defaults(__command_getter__=_command(subcommand_name))
160
+
161
+ # init
162
+ subcommand_name = "init"
163
+ parser_init = subparsers.add_parser(
164
+ subcommand_name,
165
+ help="Creates new project on current dir.",
166
+ )
167
+ parser_init.set_defaults(__command_getter__=_command(subcommand_name))
168
+
169
+ # lock
170
+ subcommand_name = "lock"
171
+ parser_lock = subparsers.add_parser(
172
+ subcommand_name,
173
+ help="Generates or updates webcompy-lock.json.",
174
+ )
175
+ parser_lock.add_argument(
176
+ "--config",
177
+ type=str,
178
+ help="Python import path for config module (e.g., my_project.webcompy_config)",
179
+ )
180
+ lock_flags = parser_lock.add_mutually_exclusive_group()
181
+ lock_flags.add_argument(
182
+ "--export",
183
+ action="store_true",
184
+ help="Export lock file dependencies to requirements.txt",
185
+ )
186
+ lock_flags.add_argument(
187
+ "--sync",
188
+ action="store_true",
189
+ help="Compare lock file with requirements.txt/pyproject.toml",
190
+ )
191
+ lock_flags.add_argument(
192
+ "--install",
193
+ action="store_true",
194
+ help="Export and install lock file dependencies",
195
+ )
196
+ parser_lock.set_defaults(__command_getter__=_command(subcommand_name))
197
+
198
+ # inspect (delegates to _inspect.py for sub-subcommand parsing)
199
+ subcommand_name = "inspect"
200
+ parser_inspect = subparsers.add_parser(
201
+ subcommand_name,
202
+ help=f"Inspect a WebComPy application. See `{maincommand} {subcommand_name} --help` for subcommands.",
203
+ )
204
+ parser_inspect.set_defaults(__command_getter__=_command(subcommand_name))
205
+
206
+ # parse
207
+ args = parser.parse_args()
208
+ if hasattr(args, "__command_getter__"):
209
+ subcommand_name = args.__command_getter__()
210
+ args_dict = {n: getattr(args, n) for n in dir(args) if not n.startswith("_")}
211
+ if (
212
+ subcommand_name == "prebuild"
213
+ and args_dict.get("embed_resources") is not None
214
+ and not args_dict.get("emit_python")
215
+ ):
216
+ parser.error("--embed-resources and --no-embed-resources require --emit-python")
217
+ if subcommand_name == "start" and args_dict.get("prebuilt") is not None:
218
+ incompatible: list[tuple[str, bool]] = [
219
+ ("--dev", bool(args_dict.get("dev"))),
220
+ ("--serve-all-deps / --no-serve-all-deps", args_dict.get("serve_all_deps") is not None),
221
+ ("--wasm-serving", args_dict.get("wasm_serving") is not None),
222
+ ("--runtime-serving", args_dict.get("runtime_serving") is not None),
223
+ ("--standalone / --no-standalone", args_dict.get("standalone") is not None),
224
+ ("--wheel-mode", args_dict.get("wheel_mode") is not None),
225
+ ]
226
+ for flag_name, is_set in incompatible:
227
+ if is_set:
228
+ parser.error(f"Cannot combine --prebuilt with {flag_name}")
229
+ return subcommand_name, args_dict
230
+ else:
231
+ parser.print_help()
232
+ sys.exit()