Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jun 16, 2022
1 parent 9bad90e commit 73e0be0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Changelog

## 0.2.0 (unreleased)
## 0.2.18 (2022.06.16)

- Provide macOS `aarch64` binary
- Reverse `--pretty` to `--no-pretty`
- Introduce colored output when pretty-printing, suppress with `--no-colors`
- Reverse `--pretty` to `--no-pretty`: pretty printing is now done by default
- Introduce colored output when pretty-printing. Defaults to `--colors auto`
which only prints colors when connected to terminal. Toggle manually with
`--colors true` or `--colors false`.
- Integrate [specter](https://github.com/redplanetlabs/specter)

## 0.1.1

Expand Down
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,16 @@ $ echo '{:a {:b {:c 1}}}' | jet --query ':a :b :c'
$ echo '{:a {:b {:c 1}}}' | jet --func '#(-> % :a :b :c)'
1

$ echo '{:a {:b {:c [1 2]}}}' | jet --thread-last ':a :b :c (map inc)'
1

$ cat /tmp/fn.clj
#(-> % :a :b :c)
$ echo '{:a {:b {:c 1}}}' | jet --func /tmp/fn.clj
1

$ echo '[1 2 3]' | jet -f '#(map inc %)'
(2 3 4)
$ echo '{:a {:a 1}}' | ./jet -t '(s/transform [s/MAP-VALS s/MAP-VALS] inc)'
{:a {:a 2}}
```

- Get the latest commit SHA and date for a project from Github:
Expand All @@ -145,7 +148,9 @@ $ curl -s https://api.github.com/repos/borkdude/clj-kondo/commits \
{:sha "bde8b1cbacb2b44ad2cd57d5875338f0926c8c0b", :date "2019-08-05T21:11:56Z"}
```

- Get raw output from query rather than wrapped in quotes
## Raw output

Get raw output from query rather than wrapped in quotes:

```shellsession
$ echo '{"a": "hello there"}' | jet --from json --keywordize --query ":a" --to edn
Expand All @@ -155,6 +160,13 @@ $ echo '{"a": "hello there"}' | jet --from json --keywordize --query ":a symbol"
hello there
```

or simply use `println` to get rid of the quotes:

``` clojure
$ echo '{"a": "hello there"}' | jet --from json --keywordize --query ":a symbol" --to edn
hello there
```

## Data readers

You can enable data readers by passing options to `--edn-reader-opts`:
Expand Down Expand Up @@ -190,8 +202,8 @@ $ echo '{"a": 1} {"a": 1}' | lein jet --from json --keywordize --collect --to ed

## Query

EDIT 2021: if the query syntax isn't clear, you can now use `--func`to pass a
normal Clojure function instead.
EDIT 2021: if the query syntax isn't clear, you can now use `--func`,
`--thread-last` or `--thread-first` to pass a normal Clojure function/expression instead.

The `--query` option supports an intermediate EDN transformation.

Expand All @@ -205,6 +217,15 @@ $ echo '{:a {:b 1}}' | jet --query '[:a :b]'
The query language should be pretty familiar to users of Clojure and `jq`. For
more information about the query language, read the docs [here](doc/query.md).

## Specter

As of version `0.2.18` the [specter](https://github.com/redplanetlabs/specter) library is available in `--func`, `--thread-first` and `--thread-last`:

``` clojure
$ echo '{:a {:a 1}}' | ./jet -t '(s/transform [s/MAP-VALS s/MAP-VALS] inc)'
{:a {:a 2}}
```

## Interactive shell

The jet interactive shell can be started with the `--interactive`
Expand Down Expand Up @@ -277,6 +298,6 @@ You will need leiningen and GraalVM.

## License

Copyright © 2019-2021 Michiel Borkent
Copyright © 2019-2022 Michiel Borkent

Distributed under the EPL License, same as Clojure. See LICENSE.
2 changes: 1 addition & 1 deletion resources/JET_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.2-SNAPSHOT
0.2.18
24 changes: 15 additions & 9 deletions src/jet/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@

(sci/eval-form ctx '(require '[camel-snake-kebab.core :as csk]))

(defn coerce-file [s]
(if (.exists (io/as-file s))
(slurp s)
s))

(defn parse-opts [options]
(let [opts (loop [options options
opts-map {}
Expand Down Expand Up @@ -71,12 +76,15 @@
{:default tagged-literal}))
help (boolean (or (get opts "--help")
(get opts "-h")))
thread-last (first (or (get opts "--thread-last")
(get opts "-t")))
thread-first (first (or (get opts "--thread-first")
(get opts "-T")))
func (or (first (or (get opts "--func")
(get opts "-f")))
thread-last (some-> (first (or (get opts "--thread-last")
(get opts "-t")))
coerce-file)
thread-first (some-> (first (or (get opts "--thread-first")
(get opts "-T")))
coerce-file)
func (or (some-> (first (or (get opts "--func")
(get opts "-f")))
coerce-file)
(when thread-first
(format "#(-> %% %s)" thread-first))
(when thread-last
Expand Down Expand Up @@ -155,9 +163,7 @@
(let [input (if query (q/query input query)
input)
input (if func
(let [f (sci/eval-string* ctx (if (.exists (io/as-file func))
(slurp func)
func))]
(let [f (sci/eval-string* ctx func)]
(f input))
input)]
(case to
Expand Down

0 comments on commit 73e0be0

Please sign in to comment.