Skip to content

Commit 9b76013

Browse files
feature: CLI 'to' supports simple names
1 parent f207504 commit 9b76013

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Sources/CLI/Convert.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,14 @@ extension Measurement: ExpressibleByArgument {
4545
}
4646
}
4747

48-
extension Units.Unit: ExpressibleByArgument {}
48+
extension Units.Unit: ExpressibleByArgument {
49+
public init?(argument: String) {
50+
if let unit = try? Self(fromName: argument) {
51+
self = unit
52+
} else if let unit = try? Self(fromSymbol: argument) {
53+
self = unit
54+
} else {
55+
return nil
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)