StructOp Handbook
Contents Examples Commands

Command line

structop [global options] <subcommand> [args]
On this page

Global options#

OptionMeaning
-chdir=DIRrun as if started in DIR
-helpprint the usage below
-versionsame as structop version

Commands that read or write state accept -environment=NAME after the subcommand to act on another environment once.

Main commands#

CommandDoesOptions
initinstalls providers into .structop/providers/ and locks their versions, including both implementations of each portable family; if any provider is refused, it installs none and writes no lock-upgrade
validatechecks names, types, references and provider rules. For portable projects it also checks source generation for both targets
planshows what apply would add, change or destroy, and which abilities cause it-detailed-exitcode (2 when there are changes), -out=FILE
apply [FILE] [-- args]generates main.c or main.rs for the selected target, compiles, records state, runs the program with args-source, -binary, -out=DIR, -no-run, -replace=ADDR
destroydeletes the program, its exports and the build folder-auto-approve

apply -out=DIR copies the generated source (-source), the program (-binary) or both to DIR; those copies are not tracked in state. A saved plan (plan -out=FILE) is applied with apply FILE only while the project, environment and state are as they were; a file saved by an earlier version must be saved again (see Lifecycle guarantees).

Add -json to validate, plan, show, test, graph, version, state list, state show, schema or init to print one JSON document instead of text. See Machine-readable output.

Other commands#

CommandDoes
fmt [-check]rewrites .st and .stvars files in the standard layout (four-space indents, = aligned, objects one item per line, a list written over several lines kept one element per line); files whose names begin with a dot are left alone; -check only lists files that would change (exit 1)
graph [-depth=N] [-ascii] [-format=text|mermaid|archify] [-changed] [-impact]draws the run order of abilities and modules in the terminal (a flowchart with a box per top-level ability; -depth=N opens N levels of frames, -ascii uses plain characters), or prints it as Mermaid or Archify; -changed marks what the plan would change and -impact also marks what those changes can affect (graph views)
test [-filter=NAME]runs tests/*.sttest; prints PASS/FAIL per run and a summary
show [FILE]prints the state, or a saved plan after checking the file
state list | show ADDR | rm ADDR | mv FROM TOinspects or edits recorded state
taint ADDR, untaint ADDRmarks a resource for rebuilding, or clears the mark
refreshre-reads recorded files from disk
import ADDR PATHtracks an existing file as a configured export
environment list | show | new NAME | select NAME | delete NAMEmanages environments
schema [KIND] [-provider=SOURCE]lists the abilities, data kinds and attributes that the providers of the project accept (the schema command)
versionprints the version of StructOp and of each locked provider
licenceshows the licence terms and whether they are accepted on this computer; licence accept accepts them, once per computer and user, before any other command runs
bind FILE.bind.st, bind -header=H [-package=P]turns a C library or a Rust crate into a provider in ~/.structop/providers/C/ or Crate/ (C libraries and Rust crates)

Environment variables#

VariableEffect
STRUCTOP_CCcompiler for generated programs (default cc)
STRUCTOP_CLANGclang used by structop bind to read headers (default clang)
STRUCTOP_CARGOa nightly cargo used by structop bind to read crates (default: the nightly toolchain through rustup)
STRUCTOP_SEEDfixes the random ability's sequence (tests set it to 1)
STRUCTOP_DEV_BINDINGSSet to 1 to load local C and Rust bindings from the user provider directory during development
STRUCTOP_PROVIDERSOverrides the installation provider directory; package verification still applies. It only changes where provider files are read from; it does not stop the provider index refresh
STRUCTOP_INDEX_FETCHSet to 0 to turn off the provider index refresh, for example on a machine with no network; structop init -upgrade then refuses to run
HOME~/.structop/providers is searched for providers

Usage text#

structop -help
Usage: structop [global options] <subcommand> [args]

Main commands:
  init          Prepare your working directory for other commands
  validate      Check whether the configuration is valid
  plan          Show changes required by the current configuration
                  -detailed-exitcode  -out=FILE (save the plan)
  apply [FILE] [-- args]  Build the application and run it with args
                  -source  -binary  -out=DIR (default out)  -no-run
                  -replace=ADDR (rebuild a resource even when unchanged)
  destroy       Delete the program, its exports and the build folder
                  -auto-approve

All other commands:
  bind FILE.bind.st  Turn a C library into a provider, guided by a hints file
                  or -header=NAME.h [-package=PKG] with every default
  fmt           Rewrite .st and .stvars files in the standard style
                  -check
  graph         Show the run order as a diagram
                  -format=mermaid (default) or -format=archify
  import ADDR PATH  Track an existing file as a configured export
  refresh       Re-read recorded files and save what is found
  test          Run the tests in tests/*.sttest (-filter=NAME)
  environment   Manage environments: list, show, new, select, delete
  show [FILE]   Show the state, or a saved plan
  state         list | show ADDR | rm ADDR | mv FROM TO
  taint ADDR    Mark a resource to be replaced by the next apply
  untaint ADDR  Remove that mark
  schema [KIND] Show what the project's providers accept (abilities, data, attributes)
                  -json  -provider=SOURCE
  version       Show the current StructOp version

Commands that read or write state act on the selected environment;
-environment=NAME after the subcommand picks another one for that run.

Global options (use these before the subcommand, if any):
  -chdir=DIR    Switch to a different working directory before executing the
                given subcommand.
  -help         Show this help output.
  -version      An alias for the "version" subcommand.