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

Printing the default value of a string enum? #62

Closed
jum opened this issue Nov 25, 2017 · 2 comments
Closed

Printing the default value of a string enum? #62

jum opened this issue Nov 25, 2017 · 2 comments

Comments

@jum
Copy link

jum commented Nov 25, 2017

I am using the following enum as an argument:

enum SyncSource: String, ArgumentConvertible {
	case finder
	case iptc
	case both

	public init(parser: ArgumentParser) throws {
    if let value = parser.shift() {
		if let value = SyncSource(rawValue: value) {
			self.init(rawValue: value.rawValue)!
		} else {
			throw ArgumentError.invalidType(value: value, type:"SyncSource", argument: nil)
		}
    } else {
		throw ArgumentError.missingValue(argument: nil)
    }
  }
  public var description: String {
	  return self.rawValue
  }
}

Even though I did implement description I do not get a default value printed for a SyncSource option declared like this:

	Option("source", default: SyncSource.both, description: "Sync attributes source \([SyncSource.finder.rawValue, SyncSource.iptc.rawValue, SyncSource.both.rawValue])"),
@kylef kylef closed this as completed in cfbcb29 Nov 25, 2017
@kylef
Copy link
Owner

kylef commented Nov 25, 2017

Hi @jum, I've added support for this in cfbcb29. Could you give it a go and ensure it is working for you?

@jum
Copy link
Author

jum commented Nov 25, 2017 via email

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