Skip to content

Commit

Permalink
Merge pull request #12 from SwiftPackageIndex/rename-argument
Browse files Browse the repository at this point in the history
Rename Argument to ShellArgument
  • Loading branch information
finestructure authored Oct 15, 2024
2 parents 8e609b6 + 6a5e133 commit 814e072
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions Sources/Argument.swift → Sources/ShellArgument.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public enum Argument: Equatable {
public enum ShellArgument: Equatable {
case quoted(QuotedString)
case verbatim(String)

Expand All @@ -13,13 +13,13 @@ public enum Argument: Equatable {
}
}

extension Argument: ExpressibleByStringLiteral {
extension ShellArgument: ExpressibleByStringLiteral {
public init(stringLiteral value: StringLiteralType) {
self = .quoted(.init(value))
}
}

extension Argument: CustomStringConvertible {
extension ShellArgument: CustomStringConvertible {
public var description: String {
switch self {
case let .quoted(value):
Expand All @@ -30,17 +30,17 @@ extension Argument: CustomStringConvertible {
}
}

extension Argument {
extension ShellArgument {
public static func url(_ url: URL) -> Self { url.absoluteString.verbatim }
}


extension StringProtocol {
public var quoted: Argument { .init(quoted: self) }
public var verbatim: Argument { .init(verbatim: self) }
public var quoted: ShellArgument { .init(quoted: self) }
public var verbatim: ShellArgument { .init(verbatim: self) }
}

extension Sequence<StringProtocol> {
public var quoted: [Argument] { map(\.quoted) }
public var verbatim: [Argument] { map(\.verbatim) }
public var quoted: [ShellArgument] { map(\.quoted) }
public var verbatim: [ShellArgument] { map(\.verbatim) }
}
2 changes: 1 addition & 1 deletion Sources/ShellOutCommand+other.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public extension ShellOutCommand {
static func bash(arguments: [Argument]) -> Self {
static func bash(arguments: [ShellArgument]) -> Self {
let arguments = arguments.first == "-c" ? Array(arguments.dropFirst()) : arguments
return .init(command: "bash", arguments: ["-c", arguments.map(\.description).joined(separator: " ")])
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/ShellOutTests/ShellOutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ final class ShellOutTests: XCTestCase {
}

func test_Argument_ExpressibleByStringLiteral() throws {
XCTAssertEqual(("foo" as Argument).description, "foo")
XCTAssertEqual(("foo bar" as Argument).description, "'foo bar'")
XCTAssertEqual(("foo" as ShellArgument).description, "foo")
XCTAssertEqual(("foo bar" as ShellArgument).description, "'foo bar'")
}

func test_Argument_url() throws {
XCTAssertEqual(Argument.url(.init(string: "https://example.com")!).description,
XCTAssertEqual(ShellArgument.url(.init(string: "https://example.com")!).description,
"https://example.com")
}

Expand Down

0 comments on commit 814e072

Please sign in to comment.