Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/einstore/shellkit
Access local shell as well as remote over SSH
https://github.com/einstore/shellkit
command-line macos nio nio2 spm ssh swift terminal ubuntu
Last synced: 4 days ago
JSON representation
Access local shell as well as remote over SSH
- Host: GitHub
- URL: https://github.com/einstore/shellkit
- Owner: Einstore
- License: mit
- Created: 2019-07-10T18:05:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-23T20:52:10.000Z (about 5 years ago)
- Last Synced: 2024-10-28T18:39:29.579Z (17 days ago)
- Topics: command-line, macos, nio, nio2, spm, ssh, swift, terminal, ubuntu
- Language: Swift
- Size: 55.7 KB
- Stars: 19
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ShellKit
Access local shell as well as remote over SSH for Swift NIO applications
### Install using SPM
```swift
.package(url: "https://github.com/Einstore/ShellKit.git", from: "1.0.0")
```### Usage
#### Connect to a local terminal
```swift
let shell = try Shell(.local, on: eventLoop)
let futureResponse = shell.run(bash: "ls -a").map { output in
print(output)
return output
}
```#### Connect to a remote service
```swift
let shell = try Shell(
.ssh(
host: "1292.168.1.2",
username: "root",
password: "sup3rS3cr3t"
),
on: eventLoop
)
let futureResponse = shell.run(bash: "ls -a")
```> Other means of SSH authentication are available!
#### Example
```swift
let eventLoop = EmbeddedEventLoop()
let shell = try Shell(.local, on: eventLoop)
let futureResponse = shell.run(bash: "cd /tmp/ ; pwd").map { output in
print(output)
return output
}.flatMapError { error in
print(error)
return error.localizedDescription
}
let out: String = try futureResponse.wait()
print(out)
```### Using `CommandKit`
Access commands through
**Example:**
```swift
shell.cmd.pwd().map { currentPath in
print(currentPath)
}
```> Discover more commands under `shell.cmd` and `shell.cmd.install`
### Author
Ondrej Rafaj @rafiki270
### License
MIT; Copyright 2019 - Einstore