Skip to content

Instantly share code, notes, and snippets.

@edma2
Created February 8, 2015 04:06
Show Gist options
  • Save edma2/787ffb173a815a089210 to your computer and use it in GitHub Desktop.
Save edma2/787ffb173a815a089210 to your computer and use it in GitHub Desktop.
#!/usr/bin/env lein exec
;; formats Clojure code from stdin, and prints formatted code to stdout
(require 'leiningen.exec)
;; Add a dependency to the classpath on the fly
(leiningen.exec/deps '[[cljfmt "0.1.7"]])
(require '[cljfmt.core :as cljfmt])
(defn- stdin-lines []
(line-seq (java.io.BufferedReader. *in*)))
(defn- stdin-string []
(clojure.string/join "\n" (stdin-lines)))
(println (cljfmt/reformat-string (stdin-string)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment