Struct ExecBuilder
Helper struct to build Exec string for desktop file.
struct ExecBuilder
;
Constructors
Name | Description |
---|---|
this
|
Construct ExecBuilder. |
Methods
Name | Description |
---|---|
argument
|
Add literal argument which is not field code. |
displayName
|
Add "%c" field code (name of application). |
file
|
Add "%f" field code. |
files
|
Add "%F" field code. |
icon
|
Add "%i" field code. |
location
|
Add "%k" field code (location of desktop file). |
result
|
Get resulting string that can be set to Exec field of Desktop Entry. The returned string is escaped. |
url
|
Add "%u" field code. |
urls
|
Add "%U" field code. |
Note
While Desktop Entry Specification says that field codes must not be inside quoted argument, ExecBuilder does not consider it as error and may create quoted argument if field code is prepended by the string that needs quotation.
Example
assert(ExecBuilder("quoted program") .icon()
.argument("-w") .displayName()
.argument("$value")
.argument("slash\\")
.argument("100%")
.location("--location=")
.urls() .url() .file("--file=") .files() .result() == `"quoted program" %i -w %c "\\$value" "slash\\\\" 100%% --location=%k %U %u --file=%f %F`);
assert(ExecBuilder("program") .argument("") .url("my url ") .result() == `program "" "my url %u"`);
assertThrown(ExecBuilder("./relative/path"));