![]() |
Limo
A simple mod manager
|
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. | |
Represents a third party tool to be run from within Limo.
enum Tool::Runtime |
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.
name | Name of the tool. |
icon_path | Path to the tool's icon. |
command | Command used to run the tool. |
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.
name | Name of the tool. |
icon_path | Path to the tool's icon. |
executable_path | Path to the tool's executable. |
working_directory | Working directory in which to run the command. |
environment_variables | Maps environment variables to their values. |
arguments | Arguments to be passed to the executable. |
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.
name | Name of the tool. |
icon_path | Path to the tool's icon. |
executable_path | Path to the tool's executable. |
prefix_path | Path to the wine prefix_path. |
working_directory | Working directory in which to run the command. |
environment_variables | Maps environment variables to their values. |
arguments | Arguments to be passed to the executable. |
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.
name | Name of the tool. |
icon_path | Path to the tool's icon. |
executable_path | Path to the tool's executable. |
use_flatpak_protontricks | Whether to use flatpak protontricks. |
steam_app_id | ID of the steam app containing the proton prefix. |
working_directory | Working directory in which to run the command. |
environment_variables | Maps environment variables to their values. |
arguments | Arguments to be passed to the executable. |
protontricks_arguments | Arguments to be passed to protontricks. |
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.
name | Name of the tool. |
icon_path | Path to the tool's icon. |
steam_app_id | ID of the steam app to run. |
use_flatpak_steam | If true: Use the flatpak version of steam. |
Tool::Tool | ( | const Json::Value & | json_object | ) |
Constructs a new Tool from data contained in the given JSON object.
json_object | Source JSON object. |
|
private |
Appends the given environment variables to the given command.
command | Command to which to append to variables. |
environment_variables | Maps environment variables to their values |
is_flatpak | If true: Command is run from within a flatpak sandbox. |
|
private |
Encloses the given string in quotes, if it is not already enclosed.
string | String to be enclosed. |
std::string Tool::getArguments | ( | ) | const |
Returns the arguments to be passed to the executable.
std::string Tool::getCommand | ( | bool | is_flatpak | ) | const |
Constructs the command used to run this tool and returns it.
is_flatpak | If true: The tool is to be run from within a flatpak sandbox. |
std::string Tool::getCommandOverwrite | ( | ) | const |
Returns the overwrite command. If this is not empty: Ignore all other settings and run this command directly.
const std::map< std::string, std::string > Tool::getEnvironmentVariables | ( | ) | const |
Returns a map containing environment variables and their values.
sfs::path Tool::getExecutablePath | ( | ) | const |
Returns the path to the executable of the tool.
sfs::path Tool::getIconPath | ( | ) | const |
Returns the path to an icon representing the tool.
std::string Tool::getName | ( | ) | const |
Return this tool's name.
sfs::path Tool::getPrefixPath | ( | ) | const |
Returns the path to the wine prefix.
std::string Tool::getProtontricksArguments | ( | ) | const |
Returns the arguments to be passed to protontricks.
Tool::Runtime Tool::getRuntime | ( | ) | const |
Returns the runtime used to run the tool.
int Tool::getSteamAppId | ( | ) | const |
Returns the ID of the steam app containing the proton prefix.
sfs::path Tool::getWorkingDirectory | ( | ) | const |
Returns the working directory in which to run the command.
Json::Value Tool::toJson | ( | ) | const |
Serializes this object to JSON.
bool Tool::usesFlatpakRuntime | ( | ) | const |
Returns true if flatpak version of protontricks or steam is used.