File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed
Sources/ArgumentParser/Parsable Types Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,12 @@ public protocol ExpressibleByArgument {
2121 var defaultValueDescription : String { get }
2222}
2323
24+ extension ExpressibleByArgument {
25+ public var defaultValueDescription : String {
26+ " \( self ) "
27+ }
28+ }
29+
2430extension String : ExpressibleByArgument {
2531 public init ? ( argument: String ) {
2632 self = argument
@@ -35,6 +41,13 @@ extension Optional: ExpressibleByArgument where Wrapped: ExpressibleByArgument {
3541 return nil
3642 }
3743 }
44+
45+ public var defaultValueDescription : String {
46+ guard let value = self else {
47+ return " none "
48+ }
49+ return " \( value) "
50+ }
3851}
3952
4053extension RawRepresentable where Self: ExpressibleByArgument , RawValue: ExpressibleByArgument {
@@ -70,17 +83,3 @@ extension Float: ExpressibleByArgument {}
7083extension Double : ExpressibleByArgument { }
7184
7285extension Bool : ExpressibleByArgument { }
73-
74- extension ExpressibleByArgument {
75-
76- public var defaultValueDescription : String {
77-
78- let mirror = Mirror ( reflecting: self )
79-
80- if mirror. displayStyle == . optional, let value = mirror. children. first? . value {
81- return " \( value) "
82- }
83-
84- return " \( self ) "
85- }
86- }
You can’t perform that action at this time.
0 commit comments