swift-argument-parser icon indicating copy to clipboard operation
swift-argument-parser copied to clipboard

Provide public method for getting an array of string arguments for a `ParsableArguments` type

Open matthewseaman opened this issue 5 years ago • 0 comments

I'd like to be able to get an array of String arguments from an already-initialized ParsableArguments type. This is useful for Driver applications that need to create some ParsableArguments type, then get the raw string arguments to pass into a child Process, which might not even be the same tool and/or cannot be run directly.

struct MyInvocation: Decodable, ParsableArguments {
    @Flag var myOption = false
}

var invocation = MyInvocation.parse([])
invocation.myOption = true

runChildProcess("myOtherTool \(invocation.rawArguments.joined(separator: " "))")

matthewseaman avatar Sep 20 '20 07:09 matthewseaman