Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

Latest commit

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ShellKit

Access local shell as well as remote over SSH for Swift NIO applications

Install using SPM

.package(url:"https://github.com/Einstore/ShellKit.git", from:"1.0.0")

Usage

Connect to a local terminal

letshell=tryShell(.local, on: eventLoop)letfutureResponse= shell.run(bash:"ls -a").map{ output inprint(output)return output
}

Connect to a remote service

letshell=tryShell(.ssh(
host:"1292.168.1.2",
username:"root",
password:"sup3rS3cr3t"),
on: eventLoop
)letfutureResponse= shell.run(bash:"ls -a")

Other means of SSH authentication are available!

Example

leteventLoop=EmbeddedEventLoop()letshell=tryShell(.local, on: eventLoop)letfutureResponse= shell.run(bash:"cd /tmp/ ; pwd").map{ output inprint(output)return output
}.flatMapError{ error inprint(error)return error.localizedDescription
}letout:String=try futureResponse.wait()print(out)

Using CommandKit

Access commands through

Example:

shell.cmd.pwd().map{ currentPath inprint(currentPath)}

Discover more commands under shell.cmd and shell.cmd.install

Author

Ondrej Rafaj @rafiki270

License

MIT; Copyright 2019 - Einstore

About

Access local shell as well as remote over SSH

Topics

Resources

Stars

19 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages