Latest | 2.1.2 |
---|---|
Homepage | https://github.com/tuist/shell |
License | MIT |
Platforms | osx 10.10, requires ARC |
Dependencies | Shell, RxSwift |
🧪 Shell
Shell is a ยต-library written Swift to run shell tasks.
Install 🛠
Swift Package Manager
Add the dependency in your Package.swift
file:
let package = Package(
name: "myproject",
dependencies: [
.package(url: "https://github.com/tuist/shell.git", .upToNextMajor(from: "2.1.2")),
],
targets: [
.target(
name: "myproject",
dependencies: ["Shell"]),
]
)
CocoaPods
Add the following line to your project Podfile:
pod "Shell", "2.1.2"
pod "ShellTesting", "2.1.2"
pod "RxShell", "2.1.2"
Carthage
Add the following line to your project Cartfile:
github "tuist/shell" "2.1.2"
Marathon
If you want to use Shell in a Marathon script, either add it to your Marathonfile
(see the Marathon repo for instructions on how to do that), or point Marathon to Shell using the inline dependency syntax:
import Shell // https://github.com/tuist/shell.git
Usage 🚀
To run commands in the system, you need to create an instance of Shell
:
let shell = Shell()
Shell exposes methods for running the commands synchronously, asynchronously, and capturing the output:
// Synchronous running
let result = shell.sync(["xcodebuild", "-project", "Shell", "-scheme", "Shell"])
// Asynchronous running
shell.async(["xcodebuild", "-project", "Shell", "-scheme", "Shell"]) { result in
// Process the result
})
// Capturing output
let result = shell.capture(["xcode-select", "-p"])
Testing ✅
We understand how inconvenient testing might be in Swift and thus, we designed Shell’s API to facilitate testing by avoiding many syntactic sugar and static interfaces. The library comes with a library, ShellTesting
that you can import in your tests target to mock the Shell
interface and stub the result of running commands:
import ShellTesting
let mock = Shell.mock()
let xcodebuild = XcodeBuild(shell: mock)
shell.succeed(["xcodebuild", "-project", "Shell.xcodeproj", "-scheme", "Shell"])
XCTAssertNoThrow(try xcodebuild.build(project: "Shell.xcodeproj", scheme: "Shell"))
RxShell 💃
Shell comes with a package, RxShell
that adds a reactive extension using RxSwift to the interface of Shell
.
subject.run(["xcodebuild", "-project", "Shell", "-scheme", "Shell"]).subscribe {
print("Compilation completed")
}
Setup for development 👩💻
- Git clone:
[email protected]:tuist/shell.git
- Generate Xcode project with
swift package generate-xcodeproj
. - Open
Shell.xcodeproj
. - Have fun 🤖
Open source
Tuist is a proud supporter of the Software Freedom Conservacy
Latest podspec
{ "name": "RxShell", "version": "2.1.2", "summary": "A extension for Shell that adds a reactive interface with RxSwift", "homepage": "https://github.com/tuist/shell", "social_media_url": "https://twitter.com/tuist", "license": "MIT", "source": { "git": "https://github.com/tuist/shell.git", "tag": "2.1.2" }, "requires_arc": true, "authors": "Tuist", "swift_version": "5.0", "platforms": { "osx": "10.10" }, "source_files": "Sources/RxShell/**/*.{swift}", "dependencies": { "Shell": [ "2.1.2" ], "RxSwift": [ "5.0.0" ] } }
Fri, 31 May 2019 10:11:19 +0000