Skip to content

Add conformances to support Swift ArgumentParser? #88

Description

@JetForMe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions