The Swift ArgumentParser library makes it easy to parse command-line arguments. I feel like it should be possible to directly provide a Path argument:
struct
Calculate : ParsableCommand
{
@Option(name: .shortAndLong, help: "Path to input word list, one per line")
var inputWordList: Path = Path.cwd/"wordlist.txt"
}
extension
Path : ExpressibleByArgument
{
public init?(argument: String) {
if let p = Path(argument)
{
self = p
}
else
{
return nil
}
}
}
but the ExpressibleByArgument conformance seems clunky to me.
The Swift ArgumentParser library makes it easy to parse command-line arguments. I feel like it should be possible to directly provide a
Path
argument:but the
ExpressibleByArgument
conformance seems clunky to me.