Skip to content

Commit 9182123

Browse files
committed
Replace .string with CustomStringConvertible .description
1 parent 37adf81 commit 9182123

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Sources/ShellOut.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ public struct ShellOutCommand {
104104
self.arguments = arguments
105105
}
106106

107-
public var string: String {
108-
([command] + arguments).joined(separator: " ")
109-
}
110-
111107
public func appending(arguments newArguments: [String]) -> Self {
112108
.init(command: command, arguments: arguments + newArguments)
113109
}
@@ -125,6 +121,12 @@ public struct ShellOutCommand {
125121
}
126122
}
127123

124+
extension ShellOutCommand: CustomStringConvertible {
125+
public var description: String {
126+
([command] + arguments).joined(separator: " ")
127+
}
128+
}
129+
128130
public extension ShellOutCommand {
129131
static func bash(arguments: [Argument]) -> Self {
130132
.init(command: "bash", arguments: ["-c", arguments.map(\.string).joined(separator: " ")])

Tests/ShellOutTests/ShellOutTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ func XCTAssertEqualAsync<T>(
2828
class ShellOutTests: XCTestCase {
2929
func test_appendArguments() throws {
3030
var cmd = ShellOutCommand(command: "foo")
31-
XCTAssertEqual(cmd.string, "foo")
31+
XCTAssertEqual(cmd.description, "foo")
3232
cmd.append(arguments: [";", "bar"])
33-
XCTAssertEqual(cmd.string, "foo ; bar" )
33+
XCTAssertEqual(cmd.description, "foo ; bar" )
3434
cmd.append(arguments: ["> baz"])
35-
XCTAssertEqual(cmd.string, "foo ; bar > baz" )
35+
XCTAssertEqual(cmd.description, "foo ; bar > baz" )
3636
}
3737

3838
func test_appendingArguments() throws {
3939
let cmd = ShellOutCommand(command: "foo")
4040
XCTAssertEqual(
41-
cmd.appending(arguments: [";", "bar"]).string,
41+
cmd.appending(arguments: [";", "bar"]).description,
4242
"foo ; bar"
4343
)
4444
XCTAssertEqual(
4545
cmd.appending(arguments: [";", "bar"])
4646
.appending(arguments: ["> baz"])
47-
.string,
47+
.description,
4848
"foo ; bar > baz"
4949
)
5050
}

0 commit comments

Comments
 (0)