CLIFoundation Documentation Beta

Structure Shell​Command

public struct ShellCommand 

Type that can be used to construct safely formated shell commands

Initializers

init(_:​)

public init(_ string: String) 

Initializes a new ShellCommand instance

Parameters

string String

The base command

Properties

raw​Command

public let rawCommand: String

The raw command that will be passed to bash

Methods

appending(flag:​should​Append:​)

public func appending(flag: String, shouldAppend: Bool = true) -> ShellCommand 

Appends a new flag to the existing command.

Parameters

flag String

The flag that will be appended.If it's a short flag one dash will be used, otherwise two will be used

should​Append Bool

A Bool indicating the flag should actually be appended or not

Returns

A new ShellCommand instance

appending(argument:​)

public func appending(argument: String?) -> ShellCommand 

Appends a new argument to the existing command.

Parameters

argument String?

The argument that will be appended

Returns

A new ShellCommand instance. If the argument is nil, the same command as before will returned

appending(option:​value:​)

public func appending(option: String, value: Any?) -> ShellCommand 

Appends a new option (key-value pair) to the existing command.

Parameters

option String

The option flag. If it's a short flag one dash will be used, otherwise two will be used

value Any?

The value that should be associated with the provided flag

Returns

A new ShellCommand instance. If the provided value is nil, the same command as before will returned