Skip to main content

Module new

Module new 

Source
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):

PlaceholderBecomes
{{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§

NewInput
What new makes.
NewOutput
What new made.

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 input gives, from the working folder cwd: its short name’s, then its file’s, then its set, 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 crate krate, on engine (at root if a checkout).
new
new: the game input asks for, made under cwd.
parse_args
Reads new’s arguments (not --json). new <template> <dir>, the older form, is new <dir> --template <template>.
plan
The game template makes for input (named name, of crate krate) under cwd, with no file written: its plan, and its limits.
text
What new made, for people.
usage
new’s usage.