Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.2.11 - 2026-07-23

### 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).

## 0.2.10 - 2026-07-22

### CLI / UX
Expand Down
2 changes: 1 addition & 1 deletion packages/create-awesome-python-app/pyproject.toml
Original file line numberDiff line numberDiff line change
@@ -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"
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
"""Create Awesome Python App CLI."""

__version__ = "0.2.10"
__version__ = "0.2.11"
Original file line numberDiff line numberDiff line change
Expand Up@@ -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).

Expand All@@ -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
Expand DownExpand Up@@ -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
Expand Down
63 changes: 63 additions & 0 deletions packages/create-awesome-python-app/tests/test_cli.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading