CLI — goga tool pybuggy init¶
Initializes the goga project and bootstraps the consumer's pybuggy environment — bare,
from a template, or as a template upgrade. Top-level command (not under endpoint);
also available as python -m goga_tool_pybuggy init.
Synopsis¶
pybuggy init— bare onboarding.pybuggy init <tpl>— template onboarding.<tpl>is a local path or a git URL of a copier-compatible template project, optionally carrying a#reffragment (https://host/repo.git#v2).--ref <git-ref>— overrides the template ref: beats the URL fragment in template mode; sets the migration target in upgrade mode.--upgrade— template migration only (the template source is read from.goga/scaffold.yml).
Modes¶
| Mode | Invocation | Behavior |
|---|---|---|
| bare | init |
Interactive onboarding of a fresh project; refused (exit 1) when .goga/ already exists — the same guard goga init applies |
| template | init <tpl> [--ref] |
Scaffold the template project first, then run the onboarding with silent-skip gates |
| upgrade | init --upgrade [--ref] |
Migrate a previously scaffolded project to a newer template version; no onboarding |
Flag rules (mirroring goga init): <tpl> and --upgrade are mutually exclusive;
--ref requires <tpl> or --upgrade. Violations print an error message and exit
with code 1.
Template mode. Scaffolding runs first (goga.scaffold engine, copier underneath):
the template is rendered into the current working directory; only project_name is
injected programmatically — the remaining template questions are asked interactively.
A failed scaffold stops the command with the engine's exit code — no onboarding side
effects are applied. After a successful scaffold the onboarding pipeline runs with
silent-skip gates: an existing file is left untouched with an INFO log and no
interactive confirmation; a missing file is created through the normal flow — including
the interactive goga questionnaire when the template brought no .goga/config.yml.
Upgrade mode. Only the template migration runs (copier run_update via the
.goga/scaffold.yml state file); no onboarding prompts appear, nothing else is
written. The state file is persisted by the template itself (the answers-file entry) —
a template without one leaves --upgrade unusable: the engine reports the missing
state file with a non-zero exit. Engine preconditions (a clean git repository, a
git-trackable template, a non-decreasing version) surface as non-zero exits; the
command propagates them without wrapping.
What the command does¶
The onboarding pipeline (bare and template modes; upgrade skips it entirely). In bare mode the
pipeline runs only in a fresh directory — an existing .goga/ is refused up front (see
Idempotency):
- Goga project config —
.goga/config.yml. When absent, the goga project is initialized in-process (offline): the language is fixed topython, the goga "Download base convention" question is not asked — no network calls — and the mandatory.goga/Dockerfileis generated. An existing config (template mode only) is silently skipped with an INFO log. - Tool config —
.goga/tools/pybuggy/config.ymlis built interactively when absent (see below). An existing file (template mode only) is silently skipped with an INFO log. - Packaged usages —
api.md/asserts.mdare copied to.goga/usages/cooks/pybuggy/when absent; an existing target file (template mode) is skipped with an INFO log. - Conventions slot —
.goga/usages/conventions.mdis created from the package asset only when absent — in every mode; an existing file (brought by a template or created/modified earlier) is left untouched. Theconventionsusage key and the annotation line are registered idempotently on every pass. - Review-executor flag —
.goga/config.ymlis brought tobuild.review_executor.skip: trueon every pass (including a skipped or declined config re-creation) — idempotently and round-trip (comments, key order and the remainingbuildcontent are preserved). - Dockerfile install line —
RUN goga install pybuggy -v 1.0.xis appended to.goga/Dockerfile; idempotent, a no-op when the Dockerfile is absent (e.g. a template without one). Together with steps 4–5 and 7 these additive augmentations are the only way pybuggy integrates itself into an arbitrary template. - Usages registration — the usage keys (
pybuggy-api,pybuggy-asserts, …,conventions) are registered incodemanifest.usages; annotation lines with backtick references are replaced or appended incodemanifest.annotations. Idempotent; user-defined keys and foreign lines are preserved. - Root conftest —
<cwd>/conftest.pyis generated from the fixed template (load_dotenv()→plugin.install()). Aconftest.pythat predates onboarding (a project without.goga/) is overwritten only on confirmation (default: no) — the one confirmation still reachable in bare mode; in template mode an existing file is silently skipped with an INFO log.
Interactive tool-config build¶
Step 2 builds .goga/tools/pybuggy/config.yml interactively when the file is missing.
What is prompted:
- Scalar plugin keys, one at a time:
base_url(required, a Jinja2 URL template — empty input is re-prompted),timeout,retries,assert_timeout,assert_delay,assert_field_class,assert_response_class. Optional keys are skipped with Enter. headersandloaderare not prompted — written as commented examples.specs: for each spec —name,type(swagger|openapi),location(required), and an optional git block (url,location,ref). Multiple specs are supported; at least one spec is required.
Skipped optional scalars are emitted as commented entries (# key:); specs is emitted
as active YAML. The generated file is valid for configuration
loading.
Idempotency¶
- Bare mode. A repeated invocation refuses up front, exactly like
goga init: when.goga/already exists the command printsProject already initializedto stderr and exits with code1— no prompts, and not a single file is updated (the copied usages are not refreshed, the configs andconftest.pyare not re-created). To re-run the onboarding, delete.goga/first. There are no--force/--dry-runflags. - Template mode. A repeated
init <tpl>re-runs the scaffold (engine semantics) and then silently skips every existing file — no prompts. - Upgrade mode. No onboarding state is touched; the migration itself is managed by the engine.
Exit codes¶
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Invalid flag combination (<tpl> with --upgrade; --ref without <tpl>/--upgrade); project already initialized (bare invocation over an existing .goga/ — zero writes); goga initialization canceled/failed |
| scaffold engine code | A failed scaffold or migration — propagated unchanged; a failed scaffold leaves no onboarding side effects |
non-zero (ClickException) |
Usages bootstrap, Dockerfile augmentation, or conftest write error |
Preconditions and side effects¶
- Requires the installed
gogapackage (a pybuggy dependency) — for the onboarding and the scaffold engine. - Writes to
<cwd>/.goga/(config, the Dockerfile install line, usages, the tool config) and<cwd>/conftest.py; the scaffold engine renders template files into<cwd>and may persist.goga/scaffold.yml(template-owned; it must not be git-ignored in a scaffolded project, or--upgradestops working). - Reads assets from the installed package (
importlib.resources), not from the checkout directory. - No network calls in bare onboarding; template/upgrade modes reach the template source (a git URL) through the engine.
- Only the
apicell usages are copied — internal development cells (config/spec/output/…) are not copied.