Skip to content

UOperatingSystemTerminalCommand

#include <OperatingSystemSimulator/Public/Programs/Terminal/OperatingSystemTerminalCommand.h>
class UOperatingSystemTerminalCommand

Defined in OperatingSystemTerminalCommand.h:88

Inherits: UObject

---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemTerminalCommand["UOperatingSystemTerminalCommand"]
  class UObject["UObject"]
  UObject <|-- UOperatingSystemTerminalCommand
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemTerminalCommand["UOperatingSystemTerminalCommand"]
  class FOperatingSystemVersion["FOperatingSystemVersion"]
  UOperatingSystemTerminalCommand *-- FOperatingSystemVersion
  class FOperatingSystemCommandFlag["FOperatingSystemCommandFlag"]
  UOperatingSystemTerminalCommand *-- FOperatingSystemCommandFlag
  class UOperatingSystemTerminal["UOperatingSystemTerminal"]
  UOperatingSystemTerminalCommand *-- UOperatingSystemTerminal
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemTerminalCommand {
    +IsSameCommand(const FString &TestCommand) bool
    +HasFlag(const FString &TestFlag) const bool
    +MainCommand : FName
    +Description : FText
    +AlternateCommands : TSet< FName >
    +SupportedOperatingSystems : FGameplayTagContainer
    +bRequiresRootPermission : uint8
    +bFailIfParametersAreFound : uint8
    +bRequireMinOperatingSystemVersion : uint8
    +MinOperatingSystemVersion : FOperatingSystemVersion()
    +CommandFlags : TSet< FOperatingSystemCommandFlag() >
    +ParentTerminal : TWeakObjectPtr< UOperatingSystemTerminal
    +AvailableFlags : TArray< FString >
    +OnValidate(FGenericError &OutError) const
    +OnProcessCommand(const FString &Command, const bool bHasRoot
    +OnProcessCommandAsRoot(const FString &Command)
    +OnContinueExecution() const
    +OnBeginDestroyCommand()
    +K2_ProcessCommand(const FString &Command)
    +K2_ProcessCommandAsRoot(const FString &Command)
    +K2_ContinueExecution()
    +CurrentCommand : FString
    +FullCommand : FString
    +CommandParameters : TArray< FString >
    +CachedWorld : TWeakObjectPtr< UWorld >
    +ProcessCommand(const FString &TestCommand, FGenericError &
    +ProcessCommandAsRoot()
    +ContinueExecution()
    +Success()
    +Fail(const FGenericError &ErrorMessage)
    +BeginCommandDestroy()
    +NotifyTerminal(const FText &Message, const EOperatingSyste
    +FinishCommand(const FGenericError ErrorIfAny)
    +GetMainCommand() const FName
    +GetCommandDescription() const FText
    +Internal_Validate(FGenericError &OutError) const
    +Internal_SetCurrentCommand(const FString &TestCommand) bool
    +Internal_GetFlagsFromCommand() const TArray< FString >
    +Internal_GetCommandParameters() const TArray< FString >
    +Internal_ValidateCommandFlags(FString &OutInvalidFlag) const bool
    +Internal_Terminate()
    +CreateCommand(const TWeakObjectPtr< UOperatingSystemTermi UOperatingSystemTerminalCommand() *
  }

Represents a command in an operating system terminal.

ReturnNameDescription
boolIsSameCommandChecks if the provided command matches the main command or any of the alternate commands. Comparison is case-insensitive.
boolHasFlag const inlineChecks if a given flag is present in the available flags and the flags obtained from the command.

bool IsSameCommand(const FString & TestCommand)

Defined in OperatingSystemTerminalCommand.h:521 Checks if the provided command matches the main command or any of the alternate commands. Comparison is case-insensitive.

  • TestCommand The command to compare against the main command and alternate commands.

True if the TestCommand matches the main command or any of the alternate commands; false otherwise.


const inline

inline bool HasFlag(const FString & TestFlag) const

Defined in OperatingSystemTerminalCommand.h:534 Checks if a given flag is present in the available flags and the flags obtained from the command.

This method checks if the specified flag is present in both the available flags and the flags obtained from the command.

  • TestFlag The flag to be checked.

True if the specified flag is present in both the available flags and the flags obtained from the command, false otherwise.

ReturnNameDescription
FNameMainCommandRepresents the command for the user to create this command object in the Operating System terminal.
FTextDescriptionA description for this command. Typically used in help.
TSet< FName >AlternateCommandsA set of alternate commands that can be used instead of the default command for the Operating System Terminal Command.
FGameplayTagContainerSupportedOperatingSystemsThe SupportedOperatingSystems property stores a collection of gameplay tags representing the supported operating systems this command object.
uint8bRequiresRootPermissionIf true, then you need to execute this in root user. Example sudo mycommand. NOTE: This setting is only valid if root command from OS is valid. Otherwise this setting has no effect.
uint8bFailIfParametersAreFoundDetermines whether the execution should fail if any parameters are found.
uint8bRequireMinOperatingSystemVersionSpecifies whether the minimum operating system version is required for the terminal command.
FOperatingSystemVersionMinOperatingSystemVersionIf enabled, this command will not execute on Operating System less than this version.
TSet< FOperatingSystemCommandFlag >CommandFlagsProperty for defining command flags in the operating system terminal command.
TWeakObjectPtr< UOperatingSystemTerminal >ParentTerminalThis property is used to store a weak pointer to the parent Operating System Terminal. It is marked as Transient, meaning that it will not be serialized when saving the object to disk.
TArray< FString >AvailableFlagsThis property represents a list of available flags of type FString. This TArray contains all the available flags that can be used in the application.

FName MainCommand

Defined in OperatingSystemTerminalCommand.h:98 Represents the command for the user to create this command object in the Operating System terminal.


FText Description

Defined in OperatingSystemTerminalCommand.h:104 A description for this command. Typically used in help.


TSet< FName > AlternateCommands

Defined in OperatingSystemTerminalCommand.h:110 A set of alternate commands that can be used instead of the default command for the Operating System Terminal Command.


FGameplayTagContainer SupportedOperatingSystems

Defined in OperatingSystemTerminalCommand.h:116 The SupportedOperatingSystems property stores a collection of gameplay tags representing the supported operating systems this command object.


uint8 bRequiresRootPermission

Defined in OperatingSystemTerminalCommand.h:122 If true, then you need to execute this in root user. Example sudo mycommand. NOTE: This setting is only valid if root command from OS is valid. Otherwise this setting has no effect.


uint8 bFailIfParametersAreFound

Defined in OperatingSystemTerminalCommand.h:132 Determines whether the execution should fail if any parameters are found.

This property is used to control the behavior of the operating system terminal command. If set to true, the command will fail if any parameters are found. If set to false, the command will proceed with execution even if parameters are found.


uint8 bRequireMinOperatingSystemVersion

Defined in OperatingSystemTerminalCommand.h:141 Specifies whether the minimum operating system version is required for the terminal command.

If set to true, the terminal command will only execute if the current operating system version is equal to or higher than the minimum operating system version.


FOperatingSystemVersion MinOperatingSystemVersion

Defined in OperatingSystemTerminalCommand.h:145 If enabled, this command will not execute on Operating System less than this version.


TSet< FOperatingSystemCommandFlag > CommandFlags

Defined in OperatingSystemTerminalCommand.h:155 Property for defining command flags in the operating system terminal command.

This property defines the command flags in the operating system terminal command. It provides a set of flags represented by the FOperatingSystemCommandFlag enum. These flags can be used to modify the behavior or execution of the terminal command.


TWeakObjectPtr< UOperatingSystemTerminal > ParentTerminal

Defined in OperatingSystemTerminalCommand.h:162 This property is used to store a weak pointer to the parent Operating System Terminal. It is marked as Transient, meaning that it will not be serialized when saving the object to disk.


TArray< FString > AvailableFlags

Defined in OperatingSystemTerminalCommand.h:169 This property represents a list of available flags of type FString. This TArray contains all the available flags that can be used in the application.

ReturnNameDescription
voidOnValidate virtual const inlineVirtual method called to validate the command before execution. This method is meant to be overridden by derived classes.
voidOnProcessCommand virtualHandles the processing of a terminal command.
voidOnProcessCommandAsRoot virtual inlineThis method is called to process a command as root in the operating system terminal.
voidOnContinueExecution virtual const inlineThis virtual method is called when the execution needs to continue.
voidOnBeginDestroyCommand virtual inlineThis method is called when a command is about to be destroyed. Can be overridden by derived classes to perform any necessary cleanup or additional actions before a command is destroyed.
voidK2_ProcessCommandCalled when a command needs to be processed in the operating system terminal. This method is a BlueprintImplementableEvent, which means it can be overridden in blueprint classes to provide custom behavior for processing commands in the operating system terminal.
voidK2_ProcessCommandAsRootK2_ProcessCommandAsRoot is a BlueprintImplementableEvent method that processes a command as root in the operating system terminal. The method is used to execute a command as root in the operating system terminal.
voidK2_ContinueExecutionA BlueprintImplementableEvent that is called to continue execution in the operating system terminal command category.

virtual const inline

virtual inline void OnValidate(FGenericError & OutError) const

Defined in OperatingSystemTerminalCommand.h:432 Virtual method called to validate the command before execution. This method is meant to be overridden by derived classes.

  • OutError A reference to an FGenericError object that will be populated with any validation errors.

virtual

virtual void OnProcessCommand(const FString & Command, const bool bHasRootPermission)

Defined in OperatingSystemTerminalCommand.h:443 Handles the processing of a terminal command.

This method is called to process a terminal command. It should be used when no root permission is required. If root permission is required, the method OnProcessCommandAsRoot should be used instead.

  • Command The terminal command to process.

  • bHasRootPermission Boolean indicating if the user has root permission.


virtual inline

virtual inline void OnProcessCommandAsRoot(const FString & Command)

Defined in OperatingSystemTerminalCommand.h:457 This method is called to process a command as root in the operating system terminal.

This method is meant to be overridden by derived classes to provide the implementation for processing a command as root in the operating system terminal. The command passed as the parameter is a string that represents the command to be executed.

  • Command A reference to a FString object that contains the command to be executed.

virtual const inline

virtual inline void OnContinueExecution() const

Defined in OperatingSystemTerminalCommand.h:467 This virtual method is called when the execution needs to continue.

Subclasses can override this method to provide specific execution logic when the execution needs to continue. It’s recommended to document the specific behavior of the overridden method in the subclass documentation.


virtual inline

virtual inline void OnBeginDestroyCommand()

Defined in OperatingSystemTerminalCommand.h:473 This method is called when a command is about to be destroyed. Can be overridden by derived classes to perform any necessary cleanup or additional actions before a command is destroyed.


void K2_ProcessCommand(const FString & Command)

Defined in OperatingSystemTerminalCommand.h:487 Called when a command needs to be processed in the operating system terminal. This method is a BlueprintImplementableEvent, which means it can be overridden in blueprint classes to provide custom behavior for processing commands in the operating system terminal.

  • Command The command to be processed in the operating system terminal.

See also: FOperatingSystemTerminalCommandInterface::ProcessCommand


void K2_ProcessCommandAsRoot(const FString & Command)

Defined in OperatingSystemTerminalCommand.h:499 K2_ProcessCommandAsRoot is a BlueprintImplementableEvent method that processes a command as root in the operating system terminal. The method is used to execute a command as root in the operating system terminal.

  • Command The command to be executed as root in the terminal. It should be a valid string representing the command.

See also: OnProcessCommandAsRoot


void K2_ContinueExecution()

Defined in OperatingSystemTerminalCommand.h:509 A BlueprintImplementableEvent that is called to continue execution in the operating system terminal command category.

This event allows for custom implementation of what should happen when the execution continues in the operating system terminal command.

See also: OnContinueExecution()

ReturnNameDescription
FStringCurrentCommandStores the current command entered by the user in the operating system terminal.
FStringFullCommandStores the full command entered by the user in the operating system terminal. The command can include flags, additional parameters, and any other valid terminal command.
TArray< FString >CommandParametersStores the command parameters entered by the user in the operating system terminal. Command parameters are the additional arguments passed along with the command.
TWeakObjectPtr< UWorld >CachedWorldA mutable weak object pointer to a UWorld instance.

FString CurrentCommand

Defined in OperatingSystemTerminalCommand.h:180 Stores the current command entered by the user in the operating system terminal.

See also: UOperatingSystemTerminalCommand


FString FullCommand

Defined in OperatingSystemTerminalCommand.h:189 Stores the full command entered by the user in the operating system terminal. The command can include flags, additional parameters, and any other valid terminal command.

See also: UOperatingSystemTerminalCommand


TArray< FString > CommandParameters

Defined in OperatingSystemTerminalCommand.h:202 Stores the command parameters entered by the user in the operating system terminal. Command parameters are the additional arguments passed along with the command.

See also: UOperatingSystemTerminalCommand


TWeakObjectPtr< UWorld > CachedWorld

Defined in OperatingSystemTerminalCommand.h:215 A mutable weak object pointer to a UWorld instance.

The CachedWorld variable allows storing and accessing a UWorld object. It is declared as mutable, meaning it can be modified even if the containing class or structure is declared as const. This mutable pointer is declared using the TWeakObjectPtr smart pointer template, which provides weak reference semantics and automatic cleanup of the referenced object when it is destroyed.

It is recommended to use the CachedWorld variable for caching and accessing the UWorld object to avoid performance overhead caused by constantly querying or searching for the UWorld instance.

ReturnNameDescription
voidProcessCommandProcesses a terminal command by performing various checks and validations.
voidProcessCommandAsRootProcesses the command as root. It first calls the OnProcessCommandAsRoot function passing the FullCommand variable as a parameter. Then, if the bHasBlueprintProcessCommandAsRoot is true, it calls the K2_ProcessCommandAsRoot function passing the FullCommand variable.
voidContinueExecutionContinue the execution of the terminal command. It calls the [OnContinueExecution()](#oncontinueexecution) method to perform any necessary operations for continuing the execution. If the terminal command has a blueprint implementation for continuing the execution, the [K2_ContinueExecution()](#k2_continueexecution) method is also called.
voidSuccessIndicates a successful completion of the operating system terminal command.
voidFailMarks the command as failed and specifies the error message.
voidBeginCommandDestroyBegins the destruction process of the operating system terminal command.
voidNotifyTerminalNotifies the terminal with a message of a specific message type.
voidFinishCommandFinish the command execution.
FNameGetMainCommand const inlineReturns the main command of the operating system terminal command.
FTextGetCommandDescription const inlineGet the description of the operating system terminal command.
voidInternal_Validate constValidates the operating system terminal command.
boolInternal_SetCurrentCommandSets the current command for the OperatingSystemTerminalCommand based on the provided TestCommand string.
TArray< FString >Internal_GetFlagsFromCommand constGets the flags from the command.
TArray< FString >Internal_GetCommandParameters constRetrieves the command parameters from the full command.
boolInternal_ValidateCommandFlags constValidates the command flags for the operating system terminal command.
voidInternal_TerminateInternal method to terminate the operating system terminal command.

void ProcessCommand(const FString & TestCommand, FGenericError & OutError)

Defined in OperatingSystemTerminalCommand.h:255 Processes a terminal command by performing various checks and validations.

  • TestCommand The terminal command to be processed.

  • OutError The reference to an object that will hold any error message if there is a problem processing the command.


void ProcessCommandAsRoot()

Defined in OperatingSystemTerminalCommand.h:264 Processes the command as root. It first calls the OnProcessCommandAsRoot function passing the FullCommand variable as a parameter. Then, if the bHasBlueprintProcessCommandAsRoot is true, it calls the K2_ProcessCommandAsRoot function passing the FullCommand variable.


void ContinueExecution()

Defined in OperatingSystemTerminalCommand.h:274 Continue the execution of the terminal command. It calls the [OnContinueExecution()](#oncontinueexecution) method to perform any necessary operations for continuing the execution. If the terminal command has a blueprint implementation for continuing the execution, the [K2_ContinueExecution()](#k2_continueexecution) method is also called.

See also: UOperatingSystemTerminalCommand::OnContinueExecution, UOperatingSystemTerminalCommand::K2_ContinueExecution


void Success()

Defined in OperatingSystemTerminalCommand.h:286 Indicates a successful completion of the operating system terminal command.

This method is called to indicate that the operating system terminal command has completed successfully. It performs the necessary cleanup by calling the Internal_Terminate() method, destroying the active command by calling ParentTerminal->DestroyActiveCommand({}), and resetting the ParentTerminal pointer by calling ParentTerminal.Reset().


void Fail(const FGenericError & ErrorMessage)

Defined in OperatingSystemTerminalCommand.h:298 Marks the command as failed and specifies the error message.

This method is called when an error occurs during the execution of a terminal command. It marks the command as failed and provides the error message that describes the cause of the failure.

  • ErrorMessage The error message that provides information about the cause of the command failure.

See also: UOperatingSystemTerminalCommand::Internal_Terminate(), UOperatingSystemTerminalCommand::DestroyActiveCommand()


void BeginCommandDestroy()

Defined in OperatingSystemTerminalCommand.h:306 Begins the destruction process of the operating system terminal command.

This method is called to initiate the destruction process of the operating system terminal command. It first removes the message listener and then calls the [OnBeginDestroyCommand()](#onbegindestroycommand) method.


void NotifyTerminal(const FText & Message, const EOperatingSystemTerminalMessageType MessageType)

Defined in OperatingSystemTerminalCommand.h:316 Notifies the terminal with a message of a specific message type.

  • Message The message to be sent to the terminal.

  • MessageType The type of the message to be sent. It can be one of the values from the enumeration EOperatingSystemTerminalMessageType.


void FinishCommand(const FGenericError ErrorIfAny)

Defined in OperatingSystemTerminalCommand.h:329 Finish the command execution.

This method is used to mark the completion of the command execution. If an error is provided, the command is considered failed. Otherwise, it is considered successful.

  • ErrorIfAny The error, if any, encountered during command execution. If non-empty, the command is considered failed. If empty, the command is considered successful.

const inline

inline FName GetMainCommand() const

Defined in OperatingSystemTerminalCommand.h:337 Returns the main command of the operating system terminal command.

The main command of the operating system terminal command.


const inline

inline FText GetCommandDescription() const

Defined in OperatingSystemTerminalCommand.h:345 Get the description of the operating system terminal command.

The description of the operating system terminal command.


const

void Internal_Validate(FGenericError & OutError) const

Defined in OperatingSystemTerminalCommand.h:376 Validates the operating system terminal command.

This method is used to validate the operating system terminal command. It checks if the main command is set, if alternate commands have a valid entry, if command flags are valid, if the minimum operating system version is set (if required), and then triggers the OnValidate method.

  • OutError The output parameter that will contain the error message if validation fails.

See also: FGenericError


bool Internal_SetCurrentCommand(const FString & TestCommand)

Defined in OperatingSystemTerminalCommand.h:384 Sets the current command for the OperatingSystemTerminalCommand based on the provided TestCommand string.

  • TestCommand The string representing the test command to set as the current command.

True if the current command is successfully set, False otherwise.


const

TArray< FString > Internal_GetFlagsFromCommand() const

Defined in OperatingSystemTerminalCommand.h:395 Gets the flags from the command.

This method parses the full command string and extracts the flags from it. Flags are defined as substrings in the command that are prefixed by a flag prefix. The flag prefixes are obtained from the parent terminal’s command flag prefixes.

An array of strings representing the flags extracted from the command.


const

TArray< FString > Internal_GetCommandParameters() const

Defined in OperatingSystemTerminalCommand.h:405 Retrieves the command parameters from the full command.

This method parses the full command to extract the command parameters. It removes the first entry, which represents the main command, and removes any entry that is a command flag or the current command itself.

An array of strings representing the command parameters.


const

bool Internal_ValidateCommandFlags(FString & OutInvalidFlag) const

Defined in OperatingSystemTerminalCommand.h:413 Validates the command flags for the operating system terminal command.

  • OutInvalidFlag [out] The reference to the variable that will store the invalid flag, if any.

true if all the command flags are valid, false otherwise.


void Internal_Terminate()

Defined in OperatingSystemTerminalCommand.h:422 Internal method to terminate the operating system terminal command.

This method is responsible for terminating the operating system terminal command. It does so by changing the current user of the terminal to the parent terminal’s current user and clearing the command flags.

ReturnNameDescription
UOperatingSystemTerminalCommand *CreateCommand staticCreates a new instance of UOperatingSystemTerminalCommand.

static

static UOperatingSystemTerminalCommand * CreateCommand(const TWeakObjectPtr< UOperatingSystemTerminal > OwningTerminal, const TSoftClassPtr< UOperatingSystemTerminalCommand > & CommandClass, FGenericError & OutError)

Defined in OperatingSystemTerminalCommand.h:242 Creates a new instance of UOperatingSystemTerminalCommand.

A pointer to the created UOperatingSystemTerminalCommand object, or nullptr if there was an error.