Skip to content

Commit

Permalink
Merge pull request #119 from Carthage/style-fixes
Browse files Browse the repository at this point in the history
[gardening] Some style fixes
  • Loading branch information
mdiep authored Dec 7, 2017
2 parents e6ad5d0 + 43c218f commit ab5f20d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
26 changes: 4 additions & 22 deletions Sources/Commandant/ArgumentProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,14 @@ extension String: ArgumentProtocol {
}
}

public extension RawRepresentable where Self.RawValue: StringProtocol, Self: ArgumentProtocol {

extension RawRepresentable where RawValue: StringProtocol, Self: ArgumentProtocol {
public static func from(string: String) -> Self? {

guard let stringValue = Self.RawValue(string)
else {
return .none
}

return Self(rawValue: stringValue)

return RawValue(string).flatMap(Self.init(rawValue:))
}

}

public extension RawRepresentable where Self.RawValue: FixedWidthInteger, Self: ArgumentProtocol {

extension RawRepresentable where RawValue: FixedWidthInteger, Self: ArgumentProtocol {
public static func from(string: String) -> Self? {

guard let intValue = Self.RawValue(string)
else {
return .none
}

return Self(rawValue: intValue)

return RawValue(string).flatMap(Self.init(rawValue:))
}

}
4 changes: 0 additions & 4 deletions Tests/CommandantTests/OptionsWithEnumProtocolSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ extension TestEnumOptions: CustomStringConvertible {
}

enum StrictStringValue: String, ArgumentProtocol {

static var name: String = "Strict string value: `foobar`, `bazbuzz`, `one`, `two`, `baz`, `a`, `b` or `c`"

case foobar
Expand All @@ -167,17 +166,14 @@ enum StrictStringValue: String, ArgumentProtocol {
case a
case b
case c

}

enum StrictIntValue: UInt8, ArgumentProtocol {

static var name: String = "Strict int value: `3`, `5`, `42`, `0`, `255`"

case min = 0
case three = 3
case giveFive = 5
case theAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything = 42
case max = 255

}

0 comments on commit ab5f20d

Please sign in to comment.