Structure
ShellCommand
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
Name | Type | Description |
---|---|---|
string | String |
The base command |
Properties
rawCommand
public let rawCommand: String
The raw command that will be passed to bash
Methods
appending(flag:shouldAppend:)
public func appending(flag: String, shouldAppend: Bool = true) -> ShellCommand
Appends a new flag to the existing command.
Parameters
Name | Type | Description |
---|---|---|
flag | String |
The flag that will be appended.If it's a short flag one dash will be used, otherwise two will be used |
shouldAppend | 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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