Commands and workflow
A plan shows what will change. Applying it builds the program, records the result so the next plan can identify changes, and then runs the program. When the program builds but fails while running, the result stays recorded: apply exits with the program’s exit status, and the next plan reports no changes. For individual flags, see the command reference.
On this page
The cycle#
$ structop init # once per project, and after changing providers $ structop validate # types, names, references; nothing is written $ structop plan # what apply would change $ structop apply # generate code, build, record state, run $ structop apply -- --verbose 3 # pass arguments to the program
apply always shows the plan first. structop fmt rewrites files in the standard layout and leaves files whose names begin with a dot alone, as the loader does; structop graph draws the run order in the terminal. structop plan lists the abilities of a list in the order the list runs, so a member that waits for a later member is planned after it.
Validation errors#
structop validate reports the first problem with its file, line and column, and suggests the nearest name:
Error: unknown component "Playr"; declare it with ability "component" "Playr" on main.st line 13, column 20 Did you mean "Player"?
Resources and state#
A project builds resources, each with an address:
| Address | What it is |
|---|---|
program.app | the selected target’s generated source (main.c or main.rs) and the compiled program |
export.NAME | a copy of the program placed where an export block says |
structop {
# ...
export "dist" {
path = "dist/dungeon-crawler"
}
}After each apply, .structop/state.json records what was built. A plan compares the configuration with that record, so it can say why a resource changes, down to the attribute (here, after editing the tour's Sleepy message):
# program.app will be replaced
~ program.app (.structop/build/app)
~ ability.print.Sleepy
message: "Shh, ${guest.name} is asleep." -> "Hush, ${guest.name} is asleep."
Plan: 0 to add, 1 to change, 0 to destroy.Working with state#
| Command | Use it to |
|---|---|
structop show | print the recorded state, or a saved plan after checking the file |
structop state list, state show ADDR | look at single resources |
structop state rm ADDR, state mv FROM TO | forget or rename a record without touching files |
structop taint ADDR / untaint ADDR | force (or cancel) a rebuild on the next apply |
structop apply -replace=ADDR | rebuild one resource now |
structop refresh | re-read the files on disk and record what is there |
structop import ADDR PATH | adopt an existing file as a configured export |
structop plan -out=FILE, apply FILE | save a plan and apply exactly that plan later; it is refused once the project, environment or state has changed |
structop destroy | remove the program, its exports and the build folder |
A lock file (.structop/lock) stops two commands writing state at once.
Environments#
Environments give one configuration separate state and build folders, for example dev and release.
$ structop environment new staging Created and switched to environment "staging"! $ structop apply # builds into .structop/env/staging/ $ structop plan -environment=default # look at another one once $ structop environment select default
default reads variables.stvars; another environment reads that file and then its own NAME.stvars over it. Use environment.name in an expression or ${environment.name} in a string to read the active name. Two environments may not export to the same path.
Testing a project#
structop test runs the run blocks in tests/*.sttest. Each run gets a fresh copy of the project, its own variable values, standard input and arguments, and checks the result:
run "says_hello" {
variables = { Example2_Name = "Ada" }
input = "Ada\n"
expect {
output_contains = "Hello, Ada"
exit_code = 0
}
}expect takes output_equals, output_contains, exit_code (0 when left out) or error_contains (validation or the build must fail with that text). See Testing for more.