class
CommandLine
Provides access to command-line arguments passed to the application.
Supports parsing parameters in various formats: -param, --param, /param, -param=value, --param=value, /param:value.
Public
Methods
staticInitialize
Initialize the command-line from argc/argv (Unix-style).
- argc
- Argument count.
- argv
- Argument values.
staticInitialize
Initialize the command-line from a single string (Windows-style).
- commandLine
- The full command-line string including executable path.
staticGet
Gets the full command-line string (excluding executable path).
staticGetExecutablePath
Get the executable path from the command-line.
Returns: The full path to the executable (e.g., "C:\Program Files\MyApp\MyApp.exe").
staticGetArgumentCount
Get the number of arguments (excluding executable).
Returns: The argument count.
staticGetArgument
Get argument at specific index (0-based, excluding executable).
- index
- The argument index (0-based).
Returns: The argument string, or empty string if index is out of bounds.
staticHasParameter
Check if a parameter exists on the command-line.
Supports formats: -param, --param, /param (case-insensitive).
- name
- The parameter name.
Returns: True if the parameter exists, false otherwise.
staticGetParameterValue
Get parameter value as string.
Supports formats: -param=value, --param=value, /param:value, -param value.
- name
- The parameter name.
- defaultValue
- The default value if parameter doesn't exist.
Returns: The parameter value, or default value if not found.
staticGetParameterValueAsInt
Get parameter value as integer.
- name
- The parameter name.
- defaultValue
- The default value if parameter doesn't exist or isn't a valid integer.
Returns: The parameter value as integer.
staticGetParameterValueAsFloat
Get parameter value as float.
- name
- The parameter name.
- defaultValue
- The default value if parameter doesn't exist or isn't a valid float.
Returns: The parameter value as float.
staticGetParameterValueAsBool
Get parameter value as boolean.
Accepts: true/false, 1/0, yes/no, on/off (case-insensitive). Switches without values return true.
- name
- The parameter name.
- defaultValue
- The default value if parameter doesn't exist.
Returns: The parameter value as boolean.
staticGetAllParameters
Get all command-line parameters as a map.
Keys are normalized to lowercase.
Returns: Const reference to the parameters map.