Last active
April 26, 2018 18:42
-
-
Save exupero/0948713cda24ced8a06ec3f1f4052e64 to your computer and use it in GitHub Desktop.
Ad hoc text transformation via Planck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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