Skip to content

@tanner0101 tanner0101 released this Aug 27, 2019 · 2 commits to master since this release

  • Command signatures are now declared using property wrappers (#116, #115)

Here's an example command signature using the new API:

struct Cowsay: Command {
    struct Signature: CommandSignature {
        @Argument(name: "message", help: "What the cow should say") 
        var message: String

        @Option(name: "eyes", short: "e", help: "Change the cow's eyes")
        var eyes: String?

        @Option(name: "tongue", short: "t", help: "Change the cow's tongue")
        var tongue: String?

        @Flag(name: "borg", help: "uses == for cow's eyes")
        var borg: Bool

        init() { }

    let help = "Prints an ASCII cow with a message"

    func run(context: CommandContext, signature: Signature) throws {
        print(signature.message) // String
        print(signature.eyes) // String?
        print(signature.tongue) // String?
        print(signature.borg) // Bool
  • New type-erased protocols for Command and Group allow for dynamic commands to be implemented (#115, #113)
struct DynamicCommand: AnyCommand {
    var help: String = ""

    func run(using context: inout CommandContext) throws {
        XCTAssertEqual(context.input.arguments, ["true", "--count", "42"])
Assets 2
You can’t perform that action at this time.