menu
info Documentation

D2S2 Command Line Interface (CLI)

Overview

The CLI version of D2S2 is available to users with a Developer license. It performs all the same simulation calculations as the standard application but without the overhead of rendering the simulation graphics, making it significantly faster to execute.

The CLI is well suited to scenarios where a graphical interface is not required or practical:

  • Automated testing — integrate D2S2 simulations into CI/CD pipelines or test harnesses to run repeatable, scripted tests with no manual interaction
  • Hardware-in-the-loop (HIL) testing — automate connection to physical hardware and drive simulation scenarios programmatically via scripts
  • Batch processing — run large numbers of scenarios sequentially or in parallel without user intervention
  • Cross-platform deployment — the CLI is available on both Windows and Linux, allowing simulations to run on servers or embedded test rigs where a desktop environment is unavailable


Usage

D2S2.exe login
D2S2.exe <task> <task parameters>

Sign in once with login (see Signing in); later tasks use that sign-in. Running the CLI application without any arguments displays the built-in help message.


Tasks

runsim

Runs a simulation from a provided scenario file.

Parameter Required Description
--scenario <file> Yes Path to the scenario file (.d2s2)
--useropts <file> No Path to the user settings file

Example:

D2S2.exe runsim --scenario c:\temp\scenario.d2s2 --useropts c:\temp\useropts.xml

runscript

Runs a scenario in conjunction with a script. Either --scriptname or --scriptopts must be specified.

Parameter Required Description
--scriptname <name> Yes* Fully qualified type name of the script to run. Use the list task to see available names.
--scriptopts <file> Yes* Path to a script options file (.d2s2-script). Can be used instead of --scriptname.
--scenario <file> No Path to the scenario file (.d2s2)
--useropts <file> No Path to the user settings file

*At least one of --scriptname or --scriptopts is required.

Examples:

D2S2.exe runscript --scriptname D2S2.Simulation.LoggingScript
D2S2.exe runscript --scriptopts c:\temp\options.d2s2-script --scenario c:\temp\scenario.d2s2 --useropts c:\temp\useropts.xml

list

Lists all available scripts by their fully qualified type names. Use these names with the --scriptname parameter of runscript and makescript.

D2S2.exe list

makescript

Saves a template script options file (.d2s2-script) with default options for the named script. Use this as a starting point before customising and passing the file to runscript.

Parameter Required Description
--scriptname <name> Yes Fully qualified type name of the script. Use the list task to see available names.
--scriptopts <file> Yes Output path for the generated script options file
--useropts <file> No Path to the user settings file

Example:

D2S2.exe makescript --scriptname D2S2.Simulation.LoggingScript --scriptopts c:\temp\options.d2s2-script

Running scripts in the cloud

If your company has cloud simulations enabled, the CLI can run a script on the D2S2 cloud simulation service instead of on your machine. You don't need a licence or plugins locally: each cloud run uses the newest released plugins. Sign in once with D2S2 login. If you signed in before cloud simulations were available, sign in again. A service account (D2S2_CLIENT_ID and D2S2_CLIENT_SECRET) needs the d2s2.sim scope.

D2S2 cloud submit --scenario scenario.d2s2 --scriptopts options.d2s2-script [--useropts usersettings.xml]
                  [--file data/tle.txt] [--label "gain 0.4"] [--cpu 0.5|1|2|4] [--timeout <minutes>]
                  [--wait [--out <folder>] [--zip]]
D2S2 cloud submit --batch sweep.json [--label <text>] [--wait [--out <folder>] [--zip]]
D2S2 cloud status [<run or batch>]
D2S2 cloud log <run> [--tail <KiB>]
D2S2 cloud results <run or batch> [--out <folder>] [--zip]
D2S2 cloud cancel <run or batch>
D2S2 cloud rerun <run> [--wait [--out <folder>] [--zip]]
D2S2 cloud entitlement
  • submit uploads the scenario, the settings and any other files (only the ones not already stored for your company) and queues the run. --file adds a file the scenario needs: a relative path such as data/tle.txt keeps its folder in the run's folder; otherwise only the file name is used.

  • --wait makes submit work like runscript. It shows the run's log as the run progresses, then downloads the output files into --out and checks them. The default folder is named after the run. The exit code is:

    • 0: the run succeeded;
    • D2S2's own exit code, if the script failed;
    • 2: the service failed the run;
    • 3: the run reached its time limit;
    • 4: the run was cancelled;
    • 1: an error, such as a wrong option or a sign-in problem;
    • 130: you stopped waiting with Ctrl+C. The run carries on.
  • Without --wait, submit prints the run's id. Use status, log and results to follow the run and download its output later.

  • Batches run several scenarios or settings in one go, such as a parameter sweep. The batch file is JSON, with paths relative to the file. Settings in defaults apply to every run, and a run's own settings override them. A run's files are added to the default files.

    {
      "label": "detumble sweep",
      "defaults": { "scriptOptions": "detumble.d2s2-script", "userSettings": "usersettings.xml", "files": ["data/tle.txt"] },
      "runs": [
        { "label": "gain 0.4", "scenario": "gain-0.4.d2s2" },
        { "label": "gain 0.6", "scenario": "gain-0.6.d2s2", "cpu": 2, "timeoutMinutes": 120 }
      ]
    }
    

    A run can set scenario, scriptOptions (or scriptName), userSettings, files, cpu, timeoutMinutes and label. Each file is uploaded once, however many runs use it.

  • submit --batch with --wait shows a line as each run ends. It then downloads each run into its own folder under --out, named after the run's label (or the run's id, when labels are missing or repeated). It also writes batch.json, listing each run's state, exit code and folder. It exits with 0 if every run succeeded, else 5.

  • status, results and cancel take a run's id or a batch's id. rerun runs a finished run again with the same inputs, as part of the same batch, using the newest released plugins.

  • Labels appear in run lists and to administrators, so don't put mission or customer names in them.

  • Each run gets 2 GiB of memory per vCPU (--cpu, default 1). The time limit (--timeout) is 60 minutes by default. D2S2 cloud entitlement shows your company's limits.


Signing in

The CLI uses the first of these that applies:

Method How Best for
E-mail and password --user <e-mail>, with the password from --pwd-stdin (read from standard input), the D2S2_PASSWORD environment variable, or --pwd <password> Accounts that can't use login
Service account The D2S2_CLIENT_ID and D2S2_CLIENT_SECRET environment variables CI/CD pipelines and test servers
Session from login D2S2.exe login once; later tasks need no sign-in options Your own machine (recommended)
Last application sign-in Nothing: the CLI uses the sign-in of the D2S2 application on the same computer Occasional use next to the application

login shows a link and a code. Open the link in any browser, on this computer or another device such as your phone, sign in as you do on the D2S2 website, and enter the code. The CLI keeps a session, not your password. The session stays valid until you run D2S2.exe logout, or until it hasn't been used for 30 days.

  • --browser opens this computer's browser instead of showing a code.
  • --mission <mission> is for accounts that sign in to a mission.
  • Sign in again if you signed in before cloud runs became available.

Service accounts sign in a CI/CD pipeline or test server without a person's account. Each one belongs to your company and uses its licence. Ask D2S2 support for one. Keep its secret in your CI system's secret store, never in scripts or source control.

Without a connection, a CLI signed in with login (or through the application) uses the licence from its last sign-in, until that licence expires.

Security note: don't pass --pwd on the command line. Other processes on the computer can see it, and it stays in your shell history. Use login, --pwd-stdin or D2S2_PASSWORD instead.


Setting Script Parameters

Script parameters — such as the output path for the Logging script — are configured via a script options file (.d2s2-script). See Scripts for instructions on generating a script options file using the makescript task.

The script options file is a JSON document where each field corresponds to a configurable property of the selected script. The following example shows a typical options file for the built-in LoggingScript:

{
  "$type": "D2S2.Simulation.LoggingScript, D2S2Library",
  "CsvFilename": "C:/temp/Logger.csv",
  "SaveObjects": "ExampleSat CubeComputer",
  "StateSaveInterval": 1,
  "UpdateVisual": false,
  "SaveStateHistory": false,
  "ScriptResult": false
}
Field Description
$type Fully qualified type name of the script. This must match the name returned by the list task.
CsvFilename Output path for the generated CSV log file.
SaveObjects Space-separated list of simulation object names whose state will be logged.
StateSaveInterval Interval (in simulation seconds) at which state is recorded.
UpdateVisual When true, updates the visual state of objects during logging. Set to false for headless/CLI use.
SaveStateHistory When true, retains the full state history in memory during the run.
ScriptResult Reserved for script result reporting. Typically set to false.

Loading User Code

User code directories are configured in the user settings file (.xml), which controls where D2S2 looks for custom scripts and components at startup. This file is generated when developer options are configured — see Developer User Settings for details. The file is located in the D2S2 installation directory, typically AppData\Roaming\D2S2.

An example user settings file is shown below:

<UserSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <LastEulaAcceptedVer>1</LastEulaAcceptedVer>
  <DeveloperLocations>
    <string>C:/temp/Source</string>
  </DeveloperLocations>
  <ShowUpdateInfo>false</ShowUpdateInfo>
  <DeveloperIncludeVis>true</DeveloperIncludeVis>
  <DeveloperIncludeWinForms>true</DeveloperIncludeWinForms>
  <OptimiseUserCode>false</OptimiseUserCode>
</UserSettings>
Field Description
DeveloperLocations List of directories to scan for user-authored scripts and components. Add one <string> entry per directory.
DeveloperIncludeVis When true, includes WPF/visual assemblies when compiling user code. Set to false for pure CLI use to reduce compilation overhead.
DeveloperIncludeWinForms When true, includes WinForms assemblies when compiling user code. Set to false if your scripts do not use WinForms UI components.
OptimiseUserCode When true, compiles user code with optimisations enabled. Useful for performance-sensitive scripts in production runs.