Skip to content

Commit dd59606

Browse files
committed
Add asString Result extension
1 parent a7a0d4c commit dd59606

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/ScriptingHelpers/ScriptingHelpers.swift

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
import Foundation
55

66
extension String: Error {}
7+
public extension Result where Success == String, Failure == String {
8+
var asString: String {
9+
switch self {
10+
case let .success(value): return value
11+
case let .failure(value): return value
12+
}
13+
}
14+
}
715

816
@discardableResult
917
public func shell(_ command: String) -> Result<String, String> {

0 commit comments

Comments
 (0)