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 <task> <task parameters> --user <username> --pwd <password>
D2S2.exe <task> <task parameters> --license <license file>

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

Authentication

The CLI supports two authentication methods:

Method Parameters Notes
Credentials --user <username> --pwd <password> Same credentials used to sign in to the UI application. If omitted, the CLI reuses the credentials from the last UI sign-in.
License file --license <license file> Provide the file path to a valid license file directly.

If neither method is specified, the CLI falls back to the credentials cached from the most recent UI sign-in. For automated or headless environments (such as CI/CD pipelines or test servers), it is recommended to use the license file method to avoid dependency on a cached session.

Security note: Avoid passing --pwd directly on the command line in shared or logged environments, as the password may be visible in process listings or shell history. Prefer the license file method for automated workflows.


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.