Skip to content

Add conformances to support Swift ArgumentParser? #88

Open

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.

Activity

  1. JetForMe commented on Jan 7, 2022

    @JetForMe
    Author

    Oh oops never mind, ExpressibleByArgument is part of ArgumentParser, not Swift.

  2. mxcl commented on Jan 10, 2022

    @mxcl
    Owner

    In general: happy to accept PRs for additions that make sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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