Create README.md

This commit is contained in:
Kare Morstol
2014-09-08 18:43:08 +02:00
parent be5b2a04c6
commit 2db569c9b8
+64
View File
@@ -0,0 +1,64 @@
# SwiftShell
A Swift module for shell scripting.
## Installation
- In the Terminal, go to where you want to download SwiftShell.
- Run
```
git clone https://github.com/kareman/SwiftShell.git
cd SwiftShell
```
- Copy/link `Div/swiftshell` to your bin folder or anywhere in your PATH.
- To install the framework, either:
- run `xcodebuild install` from the project's root folder. This will install the SwiftShell framework in ~/Library/Frameworks.
- _or_ run `xcodebuild` and copy the resulting framework from the build folder to your library folder of choice. If that is not "~/Library/Frameworks", "/Library/Frameworks" or a folder mentioned in the $DYLD_FRAMEWORK_PATH environment variable then you need to add your folder to $DYLD_FRAMEWORK_PATH.
## Examples
#### Print standard input with line numbers
```swift
#!/usr/bin/env swiftshell
import SwiftShell
var i = 1
for line in standardinput.lines() {
print("line \(i++): ")
println(line)
}
```
Launch with e.g. `ls | print_linenumbers.swift`
#### List all executables in PATH
```swift
#!/usr/bin/env swiftshell
import SwiftShell
let directories = environment["PATH"]!.split(":")
for directory in directories {
run("find \"\(directory)\" -type f -perm +ugo+x -print") |> standardoutput
}
```
#### Pipe several commands together
```swift
#!/usr/bin/env swiftshell
import SwiftShell
run("echo this is streamed") |> run("wc -w") |> standardoutput
```
## LICENSE
Copyright (c) 2014 Kåre Morstøl (NotTooBad Software).
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html