IN THIS ARTICLE
Command Line Arguments and the Settings Registry
You can edit the Settings Registry in Open 3D Engine (O3DE) with command line arguments. Command line arguments are stored in the Settings Registry. Functions to store and retrieve command line arguments are in the
Most commonly, command line arguments are used to set values in the Settings Registry. Any Settings Registry value can be overridden by specifying the JSON pointer path and the new value to set with the
--regset option. In the following example, when O3DE Editor is launched, the project path is overridden and set to
The are several command line options you can use to query and modify the Settings Registry through a JSON pointer path. This functionality is available in any application that creates a global Settings Registry through
The following applications support Settings Registry command line options:
Settings Registry supports the following command line options.
|Command Line Option||Description|
|Sets a value within the Settings Registry at the specified JSON pointer path. |
|Removes a value from the Settings Registry at the specified JSON pointer path. |
|Recursively dumps a value from the Settings Registry from the specified JSON pointer path to stdout.|
|Dumps the entire JSON document from the Settings Registry to stdout. This is equivalent to passing in the command line of |
|Merges a JSON formatted file into the Settings Registry. Files can be merged under the root empty string("") key by omitting the JSON anchor path (for example, |
Example: Merge a JSON file under the “/O3DE/Bootstrap” key
If the file path ends with
--regremove options are evaluated in left-to-right order.
This is relevant when the same options have been supplied on the command line multiple times or when a setting is both removed and set.
|Command line options||Evaluation Result|
|The “/My/Setting/value” field will be set to |
|The Settings Registry will not have a “/My/Setting/value” field due to |
|The Settings Registry will have a “/My/Setting/value” field that is set to |
|The values of the “/My/Setting” field and the “/Your/Setting” field will both be output.|
The command line that launched the application is parsed into optional and positional arguments. Then they are stored in the Settings Registry as part of
Optional arguments have an option name associated with them. In the optional argument,
--project-path /path/to/project/root, the option is
project-path and the value is
/path/to/project/root. If multiple values are associated with a single option, the values are stored in an array. Optional arguments are stored in the “/O3DE/Runtime/CommandLine/Switches” JSON pointer path.
Positional arguments don’t include an option name (or key) and are parsed based on their position in the command line. Positional arguments are stored in the “/O3DE/Runtime/CommandLine/MiscValues” JSON pointer path.
SettingsRegistryMergeUtilities provides the functions
GetCommandLineFromRegistry. These functions can be used to cache and retrieve the command line arguments supplied to O3DE applications.
//! Stores the command line settings into the Setting Registry //! The arguments can be used later anywhere the command line is needed void StoreCommandLineToRegistry(SettingsRegistryInterface& registry, const AZ::CommandLine& commandLine); //! Query the command line settings from the Setting Registry and stores them //! into the AZ::CommandLine instance bool GetCommandLineFromRegistry(SettingsRegistryInterface& registry, AZ::CommandLine& commandLine);
Refer to: SettingsRegistryMergeUtils.h