Skip to content

Instantly share code, notes, and snippets.

@exupero
Last active April 26, 2018 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exupero/0948713cda24ced8a06ec3f1f4052e64 to your computer and use it in GitHub Desktop.
Save exupero/0948713cda24ced8a06ec3f1f4052e64 to your computer and use it in GitHub Desktop.
Ad hoc text transformation via Planck
#!/usr/local/bin/planck
(require '[clojure.string :as string])
(require 'cljs.reader)
(require '[planck.core :refer [slurp eval *in* *command-line-args*]])
(def in (slurp *in*))
(defn format-output [x]
(cond
(string? x) x
(number? x) (str x)
(sequential? x) (string/join "\n" x)))
(as-> *command-line-args* $
(first $)
(cljs.reader/read-string $)
(list 'let ['s in 'l (string/split-lines in)] $)
(eval $)
(format-output $)
(js/console.log $)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment