From 6a5e133f13d5d2d1d97fc54cd447a505d593fdd6 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Mon, 14 Oct 2024 15:37:54 -0500 Subject: [PATCH] Rename Argument -> ShellArgument --- Sources/{Argument.swift => ShellArgument.swift} | 16 ++++++++-------- Sources/ShellOutCommand+other.swift | 2 +- Tests/ShellOutTests/ShellOutTests.swift | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) rename Sources/{Argument.swift => ShellArgument.swift} (64%) diff --git a/Sources/Argument.swift b/Sources/ShellArgument.swift similarity index 64% rename from Sources/Argument.swift rename to Sources/ShellArgument.swift index febdc01..224c410 100644 --- a/Sources/Argument.swift +++ b/Sources/ShellArgument.swift @@ -1,6 +1,6 @@ import Foundation -public enum Argument: Equatable { +public enum ShellArgument: Equatable { case quoted(QuotedString) case verbatim(String) @@ -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): @@ -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 { - public var quoted: [Argument] { map(\.quoted) } - public var verbatim: [Argument] { map(\.verbatim) } + public var quoted: [ShellArgument] { map(\.quoted) } + public var verbatim: [ShellArgument] { map(\.verbatim) } } diff --git a/Sources/ShellOutCommand+other.swift b/Sources/ShellOutCommand+other.swift index 4a47a13..e4f72b3 100644 --- a/Sources/ShellOutCommand+other.swift +++ b/Sources/ShellOutCommand+other.swift @@ -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: " ")]) } diff --git a/Tests/ShellOutTests/ShellOutTests.swift b/Tests/ShellOutTests/ShellOutTests.swift index 6e68845..4cb9a84 100644 --- a/Tests/ShellOutTests/ShellOutTests.swift +++ b/Tests/ShellOutTests/ShellOutTests.swift @@ -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") }