swift-argument-parser
swift-argument-parser copied to clipboard
Provide public method for getting an array of string arguments for a `ParsableArguments` type
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: " "))")