Skip to main content
Docs navigation

Command Line and Environment

A simulation built with CppModel is an ordinary program. It needs no separate command-line tool: the program itself takes the options below, reads the environment variables below and reports in its exit code whether the run passed, so CI jobs and scripts run it directly.

Simulation options​

Every simulation accepts these options, whether it is written in C, C++, Python or JavaScript. The library reads them from the process itself, so your main() doesn't need to pass them on. See Inputs from a file.

OptionEffect
--inputs <file>Takes the inputs and parameters from the file (- for stdin) instead of the workspace.

Every run is recorded in the workspace, with or without --inputs, and prints its id (Execution: <id>).

./build/FirstSimulation --inputs candidate.json   # recorded, with these values
python heater.py --inputs candidate.json # the same for Python and Node.js

Documentation upload options​

A program made with CMODEL_DOCUMENT() takes its own options. See Publishing Documentation.

OptionEffect
--project <name>Required. The documentation project in your workspace.
--docs <folder>Required. The documentation folder.
--checkChecks the folder only: nothing is uploaded and no sign-in is needed.
--helpPrints the usage.

Environment variables​

VariableEffect
CPPMODEL_USERNAME, CPPMODEL_PASSWORDLog in with these credentials instead of the browser login. Use them in scripts and CI.
CPPMODEL_LOGIN_TIMEOUTHow many seconds to wait for the browser login (default 60). 0 fails right away instead of printing a login link, which is what you want in CI.
CPPMODEL_WORKSPACEThe workspace to use when your account belongs to more than one, for example w12345. By default it comes from your account.
CPPMODEL_ACCESS_TOKENAn access token for a single run, for example one handed over by the CppModel MCP server. It takes precedence over the saved login and the credentials while it is valid, and is never stored.
CPPMODEL_REQUIREMENTS_FILEWhere the requirements a run verified are written, instead of cppmodel-requirements.json in the working directory. See Requirements.
CIWhen set (and not 0 or false) and CPPMODEL_LOGIN_TIMEOUT isn't, a run without credentials fails right away instead of waiting for the browser login.
CPPMODEL_STREAMoff (or 0, false, no) turns gprintf streams off: every sample is discarded, without signing in.
CPPMODEL_STREAM_FLUSH_MSHow often gprintf samples are sent, in milliseconds (default 500).
CPPMODEL_STREAM_BUFFERHow many gprintf samples are kept per signal until they are sent (default 10000).
CPPMODEL_STREAM_EXIT_TIMEOUT_MSHow long a gprintf flush, or the send at exit, keeps trying, in milliseconds (default 5000).

The login is saved in .cppmodeltoken in the directory the program runs from, after a browser sign-in. Keep it out of version control.

When the workspace rejects a login that has expired in the meantime, for example during a long series of runs, the library gets a new one from the saved login or the credentials and sends the request again. Recording an execution is retried for about 10 seconds when the connection fails.

Exit code​

ProgramExit code
A simulation made with CMODEL_SIMULATE or CMODEL_PERSIST, or whose main() returns result == 0 ? 0 : 10 when every step passed and the run was recorded, otherwise 1, also when the run couldn't start, for example without a login.
A documentation upload made with CMODEL_DOCUMENT()0 when the check, and the upload, passed, otherwise 1.

The exit code is only 0 or 1. The number of the first failing step is the run's result (CppModel_getSimulationResult(), C++ GetSimulationResult(), Python and Node.js run()), not the exit code: exit codes keep only 8 bits, so a failure at step 256 would exit with 0. A failure at a step whose CppModel.Step is 0 gives the result -1. To see the step in a CI log, print the result before main() returns. See Step numbers and the run's result.

Scripting the workspace​

To read results, compare executions, set the inputs and parameters for the next run, or run a simulation over many parameter values, use the CppModel MCP server from Claude Code or another AI assistant, or the workspace at workspace.cppmodel.com.

For a parameter sweep in CI, run the simulation once per case with --inputs <case.json>. Each run is recorded with its values, and its exit code says whether it passed.