GitXplorerGitXplorer
s

shake

public
122 stars
10 forks
1 issues

Commits

List of commits on branch master.
Unverified
a26b9b884fb27bdaa1700fd557a76a0a415d25fa

Merge pull request #4 from cldwalker/patch-1

ssunng87 committed 12 years ago
Unverified
7636f1d4b2ee6e7e8b2cee78b5a0d3dec4ccad57

Fix typos in readme

ccldwalker committed 12 years ago
Unverified
dd5a2c20b449a019013e5dde2fe4f55bd9223bb6

update README

ssunng87 committed 12 years ago
Unverified
096ea01597b8dbfb6184955a949a4fda7989c90e

declare-exec creates vars in shake.core

ssunng87 committed 12 years ago
Unverified
db8b0df3c90e49cb9cce406f25101fd2a9f73eb4

support three different ways of using shake

ssunng87 committed 12 years ago
Unverified
755fc196968f35088e66aab585433f7233f1b131

Merge branch 'master' of github.com:sunng87/shake

ssunng87 committed 12 years ago

README

The README file for this repository.

shake

A Clojure library that shakes your shell.

Usage

Leiningen

[shake "0.4.0"]

Just That Simple

(require '[shake.static :as sh])

;; any shell command ...
(sh/uname -a) ;;returns a #<UNIXProcess java.lang.UNIXProcess@1833160>

;; using clojure variables (vars, local bindings) in shake
(let [home "/home/sunng87"]
  (sh/ls -l $home))

;; using clojure forms in shake
(sh/curl $(format "https://github.com/%s" "sunng87"))

Too slow to initialize ?

The dynamic shake creates vars on demand. It only works in scripts/repl mode because it's by hacking the compiler.

(require '[shake.dynamic :as sh])

;; any shell command ...
(sh/uname -a) ;;returns a #<UNIXProcess java.lang.UNIXProcess@1833160>

;; using clojure variables (vars, local bindings) in shake
(let [home "/home/sunng87"]
  (sh/ls -l $home))

;; using clojure forms in shake
(sh/curl $(format "https://github.com/%s" "sunng87"))

Could not compile (no such var)

The fallback solution, declare executable before you are using it.

(require '[shake.core :as sh])

(sh/declare-exec "uname")
(sh/declare-exec "ls")
(sh/declare-exec "curl")

;; any shell command ...
(sh/uname -a) ;;returns a #<UNIXProcess java.lang.UNIXProcess@1833160>

;; using clojure variables (vars, local bindings) in shake
(let [home "/home/sunng87"]
  (sh/ls -l $home))

;; using clojure forms in shake
(sh/curl $(format "https://github.com/%s" "sunng87"))

I/O

shake extends Process with clojure's IOFactory. So you can (input-stream) or (output-stream) the process to get a streamed I/O.

;; print output of `uname -a`
(print (slurp (input-stream (sh/uname -a))))

License

Copyright © 2012 Sun Ning sunng@about.me

Distributed under the Eclipse Public License, the same as Clojure.