Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conformances to support Swift ArgumentParser? #88

Open
JetForMe opened this issue Jan 7, 2022 · 2 comments
Open

Add conformances to support Swift ArgumentParser? #88

JetForMe opened this issue Jan 7, 2022 · 2 comments

Comments

@JetForMe
Copy link

JetForMe commented Jan 7, 2022

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.

@JetForMe
Copy link
Author

JetForMe commented Jan 7, 2022

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

@mxcl
Copy link
Owner

mxcl commented Jan 10, 2022

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants