Expand description
new <dir>: a new game in dir, from the engine’s template,
templates/shuyi-default, made of parts (ADR-0013 §3,
crate::template). It is embedded in the shuyi binary, so new
needs no checkout of the engine.
The answers pick the parts: a short name of the template’s
(--template grid, --template blank), then an answers file
(--answers answers.ron), then --set <question>=<answer[,answer]>,
each in place of the one before for the questions it answers. A
question none answers takes its default. The template’s composer
(template::compose) makes the files with no I/O, and
template::apply writes them.
A template’s text files may hold these placeholders, and no others
(docs/templates.md):
| Placeholder | Becomes |
|---|---|
{{name}} | the game’s name, as given (Moon Garden) |
{{crate_name}} | its crate’s name (moon-garden) |
"{{engine.<crate>}}" | the dependency on that engine crate (shuyi, core, assets, ui, platform, app, cli) in Cargo.toml: the engine’s repository at main or at a commit, or a checkout on this machine |
{{engine_ref}} | the engine’s commit as a workflow’s uses: …@ names it: a 40-digit --engine-rev, else main |
{{engine.docs}} | a Markdown list of the engine’s rules and docs for the game’s agent: at main and on the site, at a commit, or in a checkout on this machine |
{{answer.<question>}} | that question’s answers, joined by , |
A GitHub Actions expression, ${{ … }}, is left as it is. The game’s
Rust code names its own crates game and rules (their [lib] name), so its Rust holds a placeholder only in the strings of
app_info.rs: who the game is, as app-info writes it from
shuyi.ron’s app (crate::app_info). Its one const is kept from
rustfmt, so the file new fills is the one app-info writes, whatever
the name’s length.
Structs§
Enums§
- Engine
- Where the new game gets the engine from.
Constants§
- ENGINE_
CRATES - The engine’s crates a template may depend on, by their folder under
crates/:shuyi, the front door, and the default engine’s. - ENGINE_
GIT - The engine’s repository, which a new game depends on by git.
- ENGINE_
SITE - The engine’s website, whose docs for agents follow
main.
Functions§
- answers_
of - The answers
inputgives, from the working foldercwd: its short name’s, then its file’s, then itsset, each in place of the one before for the questions it answers. - crate_
name - The crate name for game name
name: lowercase ASCII letters and digits, every other run of characters one-; it starts with a letter. - fill_
for - What fills the placeholders of a game named
name, of cratekrate, onengine(atrootif a checkout). - new
new: the gameinputasks for, made undercwd.- parse_
args - Reads
new’s arguments (not--json).new <template> <dir>, the older form, isnew <dir> --template <template>. - plan
- The game
templatemakes forinput(namedname, of cratekrate) undercwd, with no file written: its plan, and its limits. - text
- What
newmade, for people. - usage
new’s usage.