From 211419b426d42a1fdc8e203509b4e38590f9669a Mon Sep 17 00:00:00 2001 From: ulises-jeremias Date: Thu, 23 Jul 2026 10:28:25 -0300 Subject: [PATCH 1/2] fix(cli): ignore option values when peeling trailing project dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --template file://… was incorrectly setting saw_positional, so a trailing project_directory after --addons was treated as an addon slug. Co-authored-by: Cursor --- CHANGELOG.md | 6 ++ .../create-awesome-python-app/pyproject.toml | 2 +- .../src/create_awesome_python_app/__init__.py | 2 +- .../src/create_awesome_python_app/cli.py | 23 ++++++- .../tests/test_cli.py | 63 +++++++++++++++++++ uv.lock | 2 +- 6 files changed, 94 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1844125..e5edb40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.2.11 - 2026-07-23 + +### CLI / argv trailing directory + +- Do not treat `--template` / `-t` / other option *values* (e.g. `file://…`) as the project positional when expanding `--addons` / `--extend`. Fixes trailing `project_directory` being swallowed as an addon slug after a template URL (#245). + ## 0.2.10 - 2026-07-22 ### CLI / UX diff --git a/packages/create-awesome-python-app/pyproject.toml b/packages/create-awesome-python-app/pyproject.toml index 78a5023..790bfb4 100644 --- a/packages/create-awesome-python-app/pyproject.toml +++ b/packages/create-awesome-python-app/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "create-awesome-python-app" -version = "0.2.10" +version = "0.2.11" description = "Composable scaffolding CLI for production-ready Python apps" readme = "README.md" requires-python = ">=3.12" diff --git a/packages/create-awesome-python-app/src/create_awesome_python_app/__init__.py b/packages/create-awesome-python-app/src/create_awesome_python_app/__init__.py index 59c6258..c14000a 100644 --- a/packages/create-awesome-python-app/src/create_awesome_python_app/__init__.py +++ b/packages/create-awesome-python-app/src/create_awesome_python_app/__init__.py @@ -1,3 +1,3 @@ """Create Awesome Python App CLI.""" -__version__ = "0.2.10" +__version__ = "0.2.11" diff --git a/packages/create-awesome-python-app/src/create_awesome_python_app/cli.py b/packages/create-awesome-python-app/src/create_awesome_python_app/cli.py index a613fd2..05af741 100644 --- a/packages/create-awesome-python-app/src/create_awesome_python_app/cli.py +++ b/packages/create-awesome-python-app/src/create_awesome_python_app/cli.py @@ -73,6 +73,22 @@ def _preprocess_fixture_argv(argv: list[str] | None = None) -> list[str]: return out +# Flags that consume the following argv token as their value (not a positional). +_VALUE_TAKING_FLAGS = frozenset( + { + "--template", + "-t", + "--set", + "--pin", + "--refresh", + "--cache-dir", + "--fixture", + "--addons", + "--extend", + } +) + + def _expand_variadic_option(argv: list[str], option: str) -> list[str]: """Expand ``--addons a b`` into ``--addons a --addons b`` (CNA Commander parity). @@ -82,6 +98,9 @@ def _expand_variadic_option(argv: list[str], option: str) -> list[str]: When ``project_directory`` comes *after* options and no positional was seen yet, peel the final trailing token at EOS back as the directory so that ``--addons a --addons b /tmp/app`` does not treat ``/tmp/app`` as an addon. + + Option *values* (e.g. ``--template file://…``) must not set ``saw_positional``, + or a trailing directory after ``--addons`` is never peeled (#245). """ out: list[str] = [] i = 0 @@ -114,7 +133,9 @@ def _expand_variadic_option(argv: list[str], option: str) -> list[str]: i += 1 continue if i > 0 and not arg.startswith("-"): - saw_positional = True + prev = out[-1] if out else "" + if prev not in _VALUE_TAKING_FLAGS: + saw_positional = True out.append(arg) i += 1 return out diff --git a/packages/create-awesome-python-app/tests/test_cli.py b/packages/create-awesome-python-app/tests/test_cli.py index 8504782..cbd0ce8 100644 --- a/packages/create-awesome-python-app/tests/test_cli.py +++ b/packages/create-awesome-python-app/tests/test_cli.py @@ -373,6 +373,69 @@ def test_expand_preserves_trailing_project_directory() -> None: ] +def test_expand_preserves_dir_after_template_file_url() -> None: + """``--template file://…`` must not block peeling a trailing project dir (#245).""" + from create_awesome_python_app.cli import _preprocess_cli_argv + + # Single addon URL + directory at EOS (scaffold-check / L3 shape). + assert _preprocess_cli_argv( + [ + "cpa", + "--template", + "file:///tmp/cpa?subdir=templates/fastapi-starter", + "--no-interactive", + "--no-install", + "--addons", + "file:///tmp/cpa?subdir=extensions/github-setup", + "/tmp/my-api", + ] + ) == [ + "cpa", + "--template", + "file:///tmp/cpa?subdir=templates/fastapi-starter", + "--no-interactive", + "--no-install", + "--addons", + "file:///tmp/cpa?subdir=extensions/github-setup", + "/tmp/my-api", + ] + # Space-separated addons after a file:// template value. + assert _preprocess_cli_argv( + [ + "cpa", + "--template", + "file:///tmp/x", + "--addons", + "fastapi-docker", + "github-setup", + "/tmp/app", + ] + ) == [ + "cpa", + "--template", + "file:///tmp/x", + "--addons", + "fastapi-docker", + "--addons", + "github-setup", + "/tmp/app", + ] + # Short -t form. + assert ( + _preprocess_cli_argv( + [ + "cpa", + "-t", + "file:///tmp/x", + "--addons", + "github-setup", + "scaffold-check", + ] + )[-1] + == "scaffold-check" + ) + + def test_space_separated_addons_after_project_directory( tmp_path: Path, monkeypatch ) -> None: diff --git a/uv.lock b/uv.lock index e575f71..4f4808d 100644 --- a/uv.lock +++ b/uv.lock @@ -138,7 +138,7 @@ wheels = [ [[package]] name = "create-awesome-python-app" -version = "0.2.10" +version = "0.2.11" source = { editable = "packages/create-awesome-python-app" } dependencies = [ { name = "create-python-app-core" }, From fcc77d59befe288fe598208b8bb96945967ecf09 Mon Sep 17 00:00:00 2001 From: ulises-jeremias Date: Thu, 23 Jul 2026 10:30:32 -0300 Subject: [PATCH 2/2] docs(changelog): uniquify 0.2.11 heading for markdownlint MD024 Co-authored-by: Cursor --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5edb40..527e79d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 0.2.11 - 2026-07-23 -### CLI / argv trailing directory +### CLI / argv after template URL - Do not treat `--template` / `-t` / other option *values* (e.g. `file://…`) as the project positional when expanding `--addons` / `--extend`. Fixes trailing `project_directory` being swallowed as an addon slug after a template URL (#245).