Command

public struct Command

Type that can be used to construct safely formated shell commands

  • The raw command that will be passed to bash

    Declaration

    Swift

    public let rawCommand: String
  • Initializes a new ShellCommand instance

    Declaration

    Swift

    public init(_ baseCommand: String)

    Parameters

    baseCommand

    The base command

  • Initializes a new ShellCommand instance

    Declaration

    Swift

    public init(_ baseCommand: String, @CommandBuilder _ builder: () -> [CommandComponent?])

    Parameters

    baseCommand

    The base command

    builder

    The component builder closure used to construct the full command

  • Appends a new flag to the existing command.

    Declaration

    Swift

    @available(*, deprecated, renamed: "appendingFlag(_:shouldAppend:﹚")
    public func appending(flag: String, shouldAppend: Bool = true) -> Command

    Parameters

    flag

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

    shouldAppend

    A Bool indicating the flag should actually be appended or not

    Return Value

    A new ShellCommand instance

  • Appends a new flag to the existing command.

    Declaration

    Swift

    public func appendingFlag(_ flag: String, shouldAppend: Bool = true) -> Command

    Parameters

    flag

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

    shouldAppend

    A Bool indicating the flag should actually be appended or not

    Return Value

    A new ShellCommand instance

  • Appends a new argument to the existing command.

    Declaration

    Swift

    @available(*, deprecated, renamed: "appendingArgument(_:﹚")
    public func appending(argument: String?) -> Command

    Parameters

    argument

    The argument that will be appended

    Return Value

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

  • Appends a new argument to the existing command.

    Declaration

    Swift

    public func appendingArgument(_ argument: String?) -> Command

    Parameters

    argument

    The argument that will be appended

    Return Value

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

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

    Declaration

    Swift

    @available(*, deprecated, renamed: "appendingOption(_:value:﹚")
    public func appending(option: String, value: Any?) -> Command

    Parameters

    option

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

    value

    The value that should be associated with the provided flag

    Return Value

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

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

    Declaration

    Swift

    public func appendingOption(_ option: String, value: Any?) -> Command

    Parameters

    option

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

    value

    The value that should be associated with the provided flag

    Return Value

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