How to use method from protocol extension in Swift

Issue #524

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/// Any task that uses command line
public protocol UsesCommandLine: AnyObject {
var program: String { get }
var arguments: Set<String> { get set }
}

public extension UsesCommandLine {
func run() throws {
let command = "\(program) \(arguments.joined(separator: " "))"
Log.command(command)
_ = try Process().run(command: command)
}
}

class Build: UsesCommandLine {
public func run() throws {
arguments.insert("build")
try (self as UsesCommandLine).run()
}
}

Comments