Merge pull request #6 from taji-taji/fix/github-actions-deprecation set-output to $GITHUB_OUTPUT
Merge pull request #6 from taji-taji/fix/github-actions-deprecation
set-output to $GITHUB_OUTPUT
Simple shell executor with Swift.
To use the SwiftShell library in a SwiftPM project, add the following line to the dependencies in your Package.swift file:
SwiftShell
Package.swift
.package(url: "https://github.com/taji-taji/swift-shell.git", from: "1.0.0")
Include "SwiftShell" as a dependency for your executable target:
"SwiftShell"
.target(name: "<target>", dependencies: [ .product(name: "SwiftShell", package: "swift-shell"), ]),
Finally, add import SwiftShell to your source code.
import SwiftShell
import SwiftShell let shell = Shell() do { // Shell is implemented with `callAsFunction`. let output = try shell("ls", arguments: ["-l", "-a"]) print(output) } catch { print(error) }
import SwiftShell let shell = Shell() Task { async let output1 = shell("brew install awesome-tool") async let output2 = shell("bundle install") let result = try await (output1, output2) print(result.0) print(result.1) }
Execute with some Environment Variables.
try shell("brew install git", additionalEnvironment: ["HOMEBREW_NO_AUTO_UPDATE": "1"])
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Simple shell executor with Swift.
Requirements
Usage
Package.swift
To use the
SwiftShell
library in a SwiftPM project, add the following line to the dependencies in yourPackage.swift
file:Include
"SwiftShell"
as a dependency for your executable target:Finally, add
import SwiftShell
to your source code.Example
Basic Usage
Async / Await
Use Environment Variables
Execute with some Environment Variables.