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

Key and Param default value #85

Open
yonaskolb opened this issue Jan 5, 2020 · 1 comment
Open

Key and Param default value #85

yonaskolb opened this issue Jan 5, 2020 · 1 comment

Comments

@yonaskolb
Copy link
Contributor

yonaskolb commented Jan 5, 2020

It would be awesome to have an optional default value for Param and Key. This would allow:

  • setting the default value in the same place as the rest of the option configuration, instead of down in execute with option ?? defaultValue
  • allow Param and Key to have non optional types (Param already supports non optional types but currently fails if value not supplied)
  • allow an option to HelpMessageGenerator that would print the default value of options, perhaps after the description eg: " Defaults to \(defaultValue)"
@Key("--type", "-t", description: "The type of dump to output", defaultValue: .yaml)
private var dumpType: DumpType
@yonaskolb yonaskolb changed the title Key default value Key and Param default value Jan 5, 2020
@jakeheis
Copy link
Owner

This was near impossible when property wrappers were new and the Swift compiler crashed while doing just about anything with property wrappers. I think it's worth attempting this feature again now in Swift 5.4 though -- will implement when I get a chance

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