Skip to main content

Module new

Module new 

Source
Expand description

bynk new — scaffold a new project.

The zero-to-one step of the driver arc doctor → new → dev (proposal v0.58): it writes a complete, runnable single-context HTTP service that bynk dev serves unmodified. Unlike dev, new shells nothing, compiles nothing, and reads no network — it is pure, offline file-writing, so it works before bynkc, Node, or wrangler are installed (D4).

The starter, manifest, and .gitignore are embedded via include_str! (the first-party precedent, ADR 0086): each template carries a PLACEHOLDER identifier substituted for the project name at write time. A standing test (tests/new.rs) renders the starter with a non-default name and asserts it compiles and is bynk-fmt-clean, so the scaffold can never rot into something that doesn’t build.

Structs§

NewOptions
Parsed bynk new arguments.

Constants§

PLACEHOLDER
The sentinel identifier in the embedded templates, replaced by the project name when the scaffold is written. Chosen as a legal Bynk identifier so each template is itself parseable, and distinctive enough that a plain substring substitution only ever hits the intended occurrences.

Functions§

cannot_derive_message
The failure message when a name can’t be derived from the path.
clobber_message
The failure message when the target exists and isn’t empty (D5).
invalid_name_message
The failure message for a name that isn’t a legal Bynk identifier.
is_legal_name
Is name a legal Bynk identifier — a single, dotless Ident? Answered by the real lexer rather than a hand-rolled regex, so it tracks the language exactly: a dash, dot, leading digit, or reserved keyword all yield something other than one lone Ident token and are rejected.
next_steps_message
The success “next steps” message, printed to stdout.
render
Render an embedded template for name by substituting PLACEHOLDER.
run
Scaffold a new project: derive & validate the name, refuse to clobber, write the tree, and print next steps. Returns a non-zero exit (touching nothing) on an underivable/invalid name or a non-empty target.
starter_source
The rendered starter source for name — the context <name> HTTP service written to src/<name>.bynk.