Limo
A simple mod manager
Loading...
Searching...
No Matches
Tool Class Reference

Represents a third party tool to be run from within Limo. More...

#include <tool.h>

Public Types

enum  Runtime { native , wine , protontricks , steam }
 Describes how the tool is to be run. More...
 

Public Member Functions

 Tool ()=default
 Default constructor.
 
 Tool (const std::string &name, const std::filesystem::path &icon_path, const std::string &command)
 Constructs a tool that runs the given command directly.
 
 Tool (const std::string &name, const std::filesystem::path &icon_path, const std::filesystem::path &executable_path, const std::filesystem::path &working_directory, const std::map< std::string, std::string > &environment_variables, const std::string &arguments)
 Constructs a tool using the native runtime.
 
 Tool (const std::string &name, const std::filesystem::path &icon_path, const std::filesystem::path &executable_path, const std::filesystem::path &prefix_path, const std::filesystem::path &working_directory, const std::map< std::string, std::string > &environment_variables, const std::string &arguments)
 Constructs a tool using the wine runtime.
 
 Tool (const std::string &name, const std::filesystem::path &icon_path, const std::filesystem::path &executable_path, bool use_flatpak_protontricks, int steam_app_id, const std::filesystem::path &working_directory, const std::map< std::string, std::string > &environment_variables, const std::string &arguments, const std::string &protontricks_arguments)
 Constructs a tool using the protontricks runtime.
 
 Tool (const std::string &name, const std::filesystem::path &icon_path, int steam_app_id, bool use_flatpak_steam)
 Constructs a tool using the steam runtime.
 
 Tool (const Json::Value &json_object)
 Constructs a new Tool from data contained in the given JSON object.
 
std::string getCommand (bool is_flatpak) const
 Constructs the command used to run this tool and returns it.
 
Json::Value toJson () const
 Serializes this object to JSON.
 
std::string getName () const
 Return this tool's name.
 
std::filesystem::path getIconPath () const
 Returns the path to an icon representing the tool.
 
std::filesystem::path getExecutablePath () const
 Returns the path to the executable of the tool.
 
Runtime getRuntime () const
 Returns the runtime used to run the tool.
 
bool usesFlatpakRuntime () const
 Returns true if flatpak version of protontricks or steam is used.
 
std::filesystem::path getPrefixPath () const
 Returns the path to the wine prefix.
 
int getSteamAppId () const
 Returns the ID of the steam app containing the proton prefix.
 
std::filesystem::path getWorkingDirectory () const
 Returns the working directory in which to run the command.
 
std::map< std::string, std::string > const getEnvironmentVariables () const
 Returns a map containing environment variables and their values.
 
std::string getArguments () const
 Returns the arguments to be passed to the executable.
 
std::string getProtontricksArguments () const
 Returns the arguments to be passed to protontricks.
 
std::string getCommandOverwrite () const
 Returns the overwrite command. If this is not empty: Ignore all other settings and run this command directly.
 

Private Member Functions

void appendEnvironmentVariables (std::string &command, const std::map< std::string, std::string > &environment_variables, bool is_flatpak) const
 Appends the given environment variables to the given command.
 
std::string encloseInQuotes (const std::string &string) const
 Encloses the given string in quotes, if it is not already enclosed.
 

Private Attributes

std::string name_
 Name of the tool.
 
std::filesystem::path icon_path_
 Path to an icon representing the tool.
 
std::filesystem::path executable_path_
 Path to the executable of the tool.
 
Runtime runtime_
 Runtime used to run the tool.
 
bool use_flatpak_runtime_
 If runtime is proton or steam: Whether to use the flatpak version.
 
std::filesystem::path prefix_path_
 If runtime is wine: Path to the wine prefix.
 
int steam_app_id_
 If runtime is proton: ID of the steam app containing the proton prefix. If runtime is Steam: ID of the steam app to run.
 
std::filesystem::path working_directory_
 Working directory in which to run the command.
 
std::map< std::string, std::string > environment_variables_
 Maps environment variables to their values.
 
std::string arguments_
 Arguments to be passed to the executable.
 
std::string protontricks_arguments_
 Arguments to be passed to protontricks.
 
std::string command_overwrite_ = ""
 If not empty: Ignore all other settings and run this command directly.
 

Detailed Description

Represents a third party tool to be run from within Limo.

Member Enumeration Documentation

◆ Runtime

Describes how the tool is to be run.

Enumerator
native 

Tool is to be run directly.

wine 

Tool is to be run through wine.

protontricks 

Tool is to be run through proton by calling protontricks.

steam 

Tool is a steam app.

Constructor & Destructor Documentation

◆ Tool() [1/6]

Tool::Tool ( const std::string & name,
const std::filesystem::path & icon_path,
const std::string & command )

Constructs a tool that runs the given command directly.

Parameters
nameName of the tool.
icon_pathPath to the tool's icon.
commandCommand used to run the tool.

◆ Tool() [2/6]

Tool::Tool ( const std::string & name,
const std::filesystem::path & icon_path,
const std::filesystem::path & executable_path,
const std::filesystem::path & working_directory,
const std::map< std::string, std::string > & environment_variables,
const std::string & arguments )

Constructs a tool using the native runtime.

Parameters
nameName of the tool.
icon_pathPath to the tool's icon.
executable_pathPath to the tool's executable.
working_directoryWorking directory in which to run the command.
environment_variablesMaps environment variables to their values.
argumentsArguments to be passed to the executable.

◆ Tool() [3/6]

Tool::Tool ( const std::string & name,
const std::filesystem::path & icon_path,
const std::filesystem::path & executable_path,
const std::filesystem::path & prefix_path,
const std::filesystem::path & working_directory,
const std::map< std::string, std::string > & environment_variables,
const std::string & arguments )

Constructs a tool using the wine runtime.

Parameters
nameName of the tool.
icon_pathPath to the tool's icon.
executable_pathPath to the tool's executable.
prefix_pathPath to the wine prefix_path.
working_directoryWorking directory in which to run the command.
environment_variablesMaps environment variables to their values.
argumentsArguments to be passed to the executable.

◆ Tool() [4/6]

Tool::Tool ( const std::string & name,
const std::filesystem::path & icon_path,
const std::filesystem::path & executable_path,
bool use_flatpak_protontricks,
int steam_app_id,
const std::filesystem::path & working_directory,
const std::map< std::string, std::string > & environment_variables,
const std::string & arguments,
const std::string & protontricks_arguments )

Constructs a tool using the protontricks runtime.

Parameters
nameName of the tool.
icon_pathPath to the tool's icon.
executable_pathPath to the tool's executable.
use_flatpak_protontricksWhether to use flatpak protontricks.
steam_app_idID of the steam app containing the proton prefix.
working_directoryWorking directory in which to run the command.
environment_variablesMaps environment variables to their values.
argumentsArguments to be passed to the executable.
protontricks_argumentsArguments to be passed to protontricks.

◆ Tool() [5/6]

Tool::Tool ( const std::string & name,
const std::filesystem::path & icon_path,
int steam_app_id,
bool use_flatpak_steam )

Constructs a tool using the steam runtime.

Parameters
nameName of the tool.
icon_pathPath to the tool's icon.
steam_app_idID of the steam app to run.
use_flatpak_steamIf true: Use the flatpak version of steam.

◆ Tool() [6/6]

Tool::Tool ( const Json::Value & json_object)

Constructs a new Tool from data contained in the given JSON object.

Parameters
json_objectSource JSON object.

Member Function Documentation

◆ appendEnvironmentVariables()

void Tool::appendEnvironmentVariables ( std::string & command,
const std::map< std::string, std::string > & environment_variables,
bool is_flatpak ) const
private

Appends the given environment variables to the given command.

Parameters
commandCommand to which to append to variables.
environment_variablesMaps environment variables to their values
is_flatpakIf true: Command is run from within a flatpak sandbox.

◆ encloseInQuotes()

std::string Tool::encloseInQuotes ( const std::string & string) const
private

Encloses the given string in quotes, if it is not already enclosed.

Parameters
stringString to be enclosed.
Returns
The enclosed string.

◆ getArguments()

std::string Tool::getArguments ( ) const

Returns the arguments to be passed to the executable.

Returns
The arguments.

◆ getCommand()

std::string Tool::getCommand ( bool is_flatpak) const

Constructs the command used to run this tool and returns it.

Parameters
is_flatpakIf true: The tool is to be run from within a flatpak sandbox.
Returns
The command.

◆ getCommandOverwrite()

std::string Tool::getCommandOverwrite ( ) const

Returns the overwrite command. If this is not empty: Ignore all other settings and run this command directly.

Returns
The overwrite command.

◆ getEnvironmentVariables()

const std::map< std::string, std::string > Tool::getEnvironmentVariables ( ) const

Returns a map containing environment variables and their values.

Returns
The map.

◆ getExecutablePath()

sfs::path Tool::getExecutablePath ( ) const

Returns the path to the executable of the tool.

Returns
The path.

◆ getIconPath()

sfs::path Tool::getIconPath ( ) const

Returns the path to an icon representing the tool.

Returns
The path.

◆ getName()

std::string Tool::getName ( ) const

Return this tool's name.

Returns
The name.

◆ getPrefixPath()

sfs::path Tool::getPrefixPath ( ) const

Returns the path to the wine prefix.

Returns
The path.

◆ getProtontricksArguments()

std::string Tool::getProtontricksArguments ( ) const

Returns the arguments to be passed to protontricks.

Returns
The arguments.

◆ getRuntime()

Tool::Runtime Tool::getRuntime ( ) const

Returns the runtime used to run the tool.

Returns
The runtime.

◆ getSteamAppId()

int Tool::getSteamAppId ( ) const

Returns the ID of the steam app containing the proton prefix.

Returns
The ID.

◆ getWorkingDirectory()

sfs::path Tool::getWorkingDirectory ( ) const

Returns the working directory in which to run the command.

Returns
The path.

◆ toJson()

Json::Value Tool::toJson ( ) const

Serializes this object to JSON.

Returns
The resulting JSON object.

◆ usesFlatpakRuntime()

bool Tool::usesFlatpakRuntime ( ) const

Returns true if flatpak version of protontricks or steam is used.

Returns
The status.

The documentation for this class was generated from the following files: