Skip to content

Commit 710a17e

Browse files
committed
refactor: CLI interface to use streaming processor
1 parent b8d24d7 commit 710a17e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: cli/jq/cli.clj

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
(println summary))
2525

2626
(defn execute [jq-filter files _]
27-
(let [jq-processor (jq/flexible-processor jq-filter {:output :json-node})]
27+
(let [jq-processor (jq/stream-processor jq-filter)]
2828
(if (seq files)
2929
(doseq [f files
30-
item (jq-processor (slurp f))]
30+
item (jq-processor (jq/string->json-node (slurp f)))]
3131
(println (jq/json-node->string item)))
3232
(when (.ready ^Reader *in*)
3333
(doseq [^String line (line-seq (BufferedReader. *in*))
34-
item (jq-processor line)]
34+
item (jq-processor (jq/string->json-node line))]
3535
(println (jq/json-node->string item)))))))
3636

3737
(defn -main [& args]

Diff for: src/jq/api.clj

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
; required in common use cases, so moving out of impl space
1010
(def json-node->string impl/json-node->string)
11+
(def string->json-node impl/string->json-node)
1112

1213
; jq docs http://manpages.ubuntu.com/manpages/hirsute/man1/jq.1.html
1314
(defn execute

0 commit comments

Comments
 (0)