flock-cli
flock-cli
A Rails-like command-line tool for the Flock game engine: scaffold a project, generate components/systems/plugins, run it with hot reload, build it (native or WebAssembly), and bundle its assets.
Namespace Flock::Cli. Pure Crystal standard library — no third-party dependencies.
Prerequisites
- Crystal
>= 1.16.0on yourPATH(build/run/devshell out tocrystal build). - The Flock ecosystem checkout — a directory that contains
flock/(plusflock-collision/,flock-tilemap/,flock-ldtk/if you use those features). The CLI locates it, in order, via:flock new --flock-path PATH,- the
FLOCK_PATHenvironment variable, - otherwise the parent-of-parent of the
flockbinary (so a checkout laid out as.../native-wgpu/{flock,flock-cli,…}just works).
- SDL3 + a GPU runtime to actually run a game (required by the engine, not by the CLI).
- Web target only: the project must provide
web/build.sh/web/dev.sh(theweshWASM toolchain). Native projects don't have these and the CLI says so if you ask for--target web.
Install
cd flock-cli
shards build # -> bin/flock
Put bin/flock on your PATH (or call it directly). No shards install is needed — there are no dependencies.
flock version # flock 0.1.0
flock help
Quick start
flock new mygame --2d
cd mygame
flock g component Velocity dx:f32 dy:f32
flock g entity Player Velocity
flock g system Movement --schedule update
flock dev # builds, runs, and rebuilds+restarts on every save
Commands
| Command (alias) | Syntax | Effect |
|---|---|---|
new |
flock new NAME [--2d|--3d] [--tilemap] [--ldtk] [--collision] [--flock-path PATH] |
Scaffold a new project in NAME/. --2d is the default; feature flags are additive. |
generate (g) |
flock g TYPE NAME [args…] |
Generate a source file (see Generators). |
destroy (d) |
flock d TYPE NAME |
Delete the file a generator made (safe: stays inside src/<dir>/). |
dev |
flock dev [--target web|native] |
Build, run, and hot-reload on file changes. --web is shorthand for --target web. |
build |
flock build [--release] [--target web|native] |
Compile to bin/<name> (native) or WASM via web/build.sh. |
run |
flock run [--release] [-- game-args…] |
Build then run once; everything after -- is passed to the game. |
pack |
flock pack [dir] [-o out.flkpack] |
Bundle a directory (default assets) into a .flkpack archive. |
version |
flock version |
Print the CLI version. |
help |
flock help |
Print usage. |
Every command except new must run inside a project — the directory the CLI marks with .flock/config.json. Outside one you get not a flock project (missing ./.flock/config.json).
dev — hot reload
- Native (default): polls
src/**/*.crandassets/**/*; on any add/edit/delete it rebuilds and restarts the game. A failing build keeps the watcher alive.Ctrl-Cstops the child gracefully (SIGTERM, then SIGKILL after a short grace period). - Web (
--target web): delegates to the project'sweb/dev.sh(theweshWASM dev loop).
run — argument splitting
Args before a literal -- are the CLI's; everything after goes to the game:
flock run --release -- --level 3 --debug # --release builds; --level/--debug reach the game
Generators
flock g TYPE NAME [args…] — destroy takes the same types. Names accept player-health, player_health, or PlayerHealth: files are snake_case, types are CamelCase.
| Type (alias) | Syntax | Output | Generates |
|---|---|---|---|
component (c) |
flock g c NAME [field:type…] |
src/components/<name>.cr |
a struct including Flock::Component, one property per field |
resource (r) |
flock g r NAME [field:type…] |
src/resources/<name>.cr |
a class < Flock::Resource with properties |
entity (e) |
flock g e NAME [Component…] |
src/entities/<name>.cr |
a spawn_<name>(world, position) that spawns a Transform (+Sprite in 2D) with each component |
system (s) |
flock g s NAME [--schedule S] |
src/systems/<name>.cr |
a system function, auto-registered in the given schedule |
plugin (p) |
flock g p NAME |
src/plugins/<name>.cr |
a <Name>Plugin < Flock::Plugin, auto-registered |
Field types (component, resource)
name:type pairs; a bare name defaults to Float32.
flock g component Position x:f32 y:f32
flock g component Target who:entity range:f32
| Key(s) | Crystal type | Default |
|---|---|---|
f32 float float32 |
Float32 |
0.0f32 |
f64 float64 |
Float64 |
0.0 |
i32 int int32 |
Int32 |
0 |
i64 |
Int64 |
0_i64 |
u32 |
UInt32 |
0_u32 |
bool |
Bool |
false |
str string |
String |
"" |
vec2 |
Flock::Vec2 |
zero |
vec3 |
Flock::Vec3 |
zero |
color |
Flock::Color |
WHITE |
entity |
Flock::Entity |
required (no default) |
entity fields have no default, so they are ordered first in the generated initialize.
System schedules
--schedule accepts first, update (default), fixed / fixedupdate, render, last.
Generated project layout
NAME/
.flock/config.json # {name, dim, features, flock_path} — marks a flock project
shard.yml # Flock shards as relative-path deps; no `shards install`
.gitignore
README.md
src/
NAME.cr # entry: requires the stack, builds the App, applies Registry, runs
registry.cr # PLUGINS / STARTUPS / SYSTEMS + apply
components/.keep.cr # each dir seeded so `require "./dir/*"` resolves
entities/.keep.cr
systems/.keep.cr
resources/.keep.cr
plugins/.keep.cr
assets/
.gitkeep
world.ldtk # only with --ldtk (a starter 8x6 IntGrid level)
The entry src/NAME.cr opens a 960×540 window and installs a starter scene that matches the chosen features (2D sprite, 3D cube, 2D/3D collision floor + falling boxes, or a framed LDtk level). Shards are referenced by relative path, so the tree is portable and needs no shards install.
End-to-end examples
Physics project, ship a release build, bundle assets:
flock new arena --2d --collision
cd arena
flock run # build + run once (floor + falling boxes)
flock build --release # -> bin/arena
flock pack assets -o arena.flkpack
LDtk 2D project, then a web build:
flock new platformer --ldtk # writes assets/world.ldtk
cd platformer
flock dev # native hot reload
flock build --target web # requires web/build.sh (wesh)
License
MIT — see LICENSE.
flock-cli
- 0
- 0
- 0
- 0
- 0
- about 7 hours ago
- August 19, 2026
MIT License
Wed, 19 Aug 2026 12:18:29 GMT