Skip to content

Commit

Permalink
Update package
Browse files Browse the repository at this point in the history
  • Loading branch information
vmanot committed Nov 23, 2024
1 parent 8c212a2 commit 8b0d696
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 18 deletions.
31 changes: 16 additions & 15 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var package = Package(
name: "Merge",
targets: [
"CommandLineToolSupport",
"Shell",
"ShellScripting",
"SwiftDI",
"Merge"
]
Expand All @@ -36,46 +36,47 @@ var package = Package(
]
),
.target(
name: "CommandLineToolSupport",
name: "Merge",
dependencies: [
"Swallow",
.product(name: "SwallowMacrosClient", package: "Swallow"),
"SwiftDI"
],
path: "Sources/CommandLineToolSupport",
path: "Sources/Merge",
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport")
]
),
.target(
name: "Merge",
name: "ShellScripting",
dependencies: [
"CommandLineToolSupport",
"Swallow",
.product(name: "SwallowMacrosClient", package: "Swallow"),
"SwiftDI"
"Merge"
],
path: "Sources/Merge",
path: "Sources/ShellScripting",
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport")
]
),
.target(
name: "Shell",
name: "CommandLineToolSupport",
dependencies: [
"Merge"
"Merge",
"ShellScripting",
"Swallow",
],
path: "Sources/Shell",
path: "Sources/CommandLineToolSupport",
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport")
]
),
.testTarget(
name: "MergeTests",
dependencies: [
"CommandLineToolSupport",
"Merge",
"Shell",
"ShellScripting",
],
path: "Tests"
)
],
swiftLanguageVersions: [.v5]
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,30 @@
//

import Foundation
import Swift
import Merge

open class AnyCommandLineTool {
public var environmentVariables: [String: any CLT.EnvironmentVariableValue] = [:]
public var currentDirectoryURL: URL? = nil

public init() {

}
}

extension AnyCommandLineTool {
@discardableResult
public func withUnsafeSystemShell<R>(
perform operation: (SystemShell) async throws -> R
) async throws -> R {
let shell = SystemShell(
environment: environmentVariables.mapValues({ String(describing: $0) }),
currentDirectoryURL: currentDirectoryURL,
options: [._forwardStdoutStderr]
)

let result: R = try await operation(shell)

return result
}
}
1 change: 0 additions & 1 deletion Sources/Merge/module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Copyright (c) Vatsal Manot
//

@_exported import CommandLineToolSupport
@_exported import Diagnostics
@_exported import Combine
@_exported import Swallow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Merge
internal import Swallow
import Swift

@available(*, deprecated)
public func shq(
_ cmd: String,
arguments: [Process.ArgumentLiteral] = [],
Expand All @@ -24,6 +25,7 @@ public func shq(
._runSynchronously()
}

@available(*, deprecated)
@_disfavoredOverload
public func shq(
_ cmd: String,
Expand All @@ -39,6 +41,7 @@ public func shq(
)
}

@available(*, deprecated)
public func shq(
_ cmd: String,
arguments: [String],
Expand All @@ -54,6 +57,7 @@ public func shq(
.validate()
}

@available(*, deprecated)
public func shq(
_ cmd: String,
arguments: [Process.ArgumentLiteral] = [],
Expand All @@ -69,6 +73,7 @@ public func shq(
._runAsynchronously()
}

@available(*, deprecated)
@_disfavoredOverload
public func shq(
_ cmd: String,
Expand All @@ -84,6 +89,7 @@ public func shq(
)
}

@available(*, deprecated)
public func shq(
_ cmd: String,
arguments: [String],
Expand All @@ -99,6 +105,7 @@ public func shq(
.validate()
}

@available(*, deprecated)
public func shq<D: Decodable>(
_ type: D.Type,
decodedBy jsonDecoder: JSONDecoder = .init(),
Expand All @@ -116,6 +123,7 @@ public func shq<D: Decodable>(
.decode(type, using: jsonDecoder)
}

@available(*, deprecated)
public func shq<D: Decodable>(
_ type: D.Type,
decodedBy jsonDecoder: JSONDecoder = .init(),
Expand All @@ -132,6 +140,7 @@ public func shq<D: Decodable>(
return try await process._runAsynchronously().stdout.decode(type, using: jsonDecoder)
}

@available(*, deprecated)
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
public func shq(
_ sink: Process.StandardOutputSink,
Expand All @@ -148,6 +157,7 @@ public func shq(
try process._runSynchronouslyRedirectingAllOutput(to: sink)
}

@available(*, deprecated)
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
public func shq(
_ sink: Process.StandardOutputSink,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Tests/ProcessInitializerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Vatsal Manot
//

@testable import Shell
@testable import ShellScripting
import XCTest

class ShellProcessTests: XCTestCase {
Expand Down

0 comments on commit 8b0d696

Please sign in to comment.