ExecBuilder

Helper struct to build Exec string for desktop file. 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.

Constructors

this
this(string executable)

Construct ExecBuilder.

Members

Functions

argument
ExecBuilder argument(string arg, Flag!"forceQuoting" forceQuoting = No.forceQuoting)

Add literal argument which is not field code.

displayName
ExecBuilder displayName(string prepend = null)

Add "%c" field code (name of application).

file
ExecBuilder file(string prepend = null)

Add "%f" field code.

files
ExecBuilder files()

Add "%F" field code.

icon
ExecBuilder icon()

Add "%i" field code.

location
ExecBuilder location(string prepend = null)

Add "%k" field code (location of desktop file).

result
string result()

Get resulting string that can be set to Exec field of Desktop Entry. The returned string is escaped.

url
ExecBuilder url(string prepend = null)

Add "%u" field code.

urls
ExecBuilder urls()

Add "%U" field code.

Examples

1 assert(ExecBuilder("quoted program").icon()
2         .argument("-w").displayName()
3         .argument("$value")
4         .argument("slash\\")
5         .argument("100%")
6         .location("--location=")
7         .urls().url().file("--file=").files().result() == `"quoted program" %i -w %c "\\$value" "slash\\\\" 100%% --location=%k %U %u --file=%f %F`);
8 
9 assert(ExecBuilder("program").argument("").url("my url ").result() == `program "" "my url %u"`);
10 
11 assertThrown(ExecBuilder("./relative/path"));

Meta