SwiftCLI
SwiftCLI copied to clipboard
Key and Param default value
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
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