-
Notifications
You must be signed in to change notification settings - Fork 0
/
eql
executable file
·50 lines (38 loc) · 1.53 KB
/
eql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bb
;; -*- mode: clojure -*-
;; DO NOT EDIT DIRECTLY. GENERATED FROM src/town/lilac/eql.clj
(require '[babashka.deps :as deps])
(deps/add-deps
'{:deps {org.babashka/cli {:mvn/version "0.3.34"}
org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}
town.lilac/pyramid {:mvn/version "3.3.0"}}})
(ns town.lilac.eql
(:require
[babashka.cli :as cli]
[clojure.edn :as edn]
[pyramid.core :as p]))
(def version "0.0.1")
(def cli-spec
{:query {:ref "<query>"
:desc "EQL query to run on the input data."
:alias :q}
:to-query {:desc "Return a valid EQL query for the entire input data."}})
(defn -main
[& opts]
(let [{:keys [opts args]} (cli/parse-args opts {:spec cli-spec})
data #(if (some? (first args))
(edn/read-string (first args))
(edn/read *in*))]
(cond
(contains? opts :to-query) (p/data->query (data))
(contains? opts :query) (->> (:query opts)
(edn/read-string)
(p/pull (data)))
:else (do (println (str "eql v" version))
(println "Usage: eql <options> <data>")
(println "If data is elided, expects it to be sent via stdin.")
(newline)
(println (cli/format-opts {:spec cli-spec}))))))
(when (= *file* (System/getProperty "babashka.file"))
(apply -main *command-line-args*))