Skip to content

Commit 466aaff

Browse files
authored
[patch] ✨ Add primitive functions (#4)
* ✨ Add primitive functions Signed-off-by: Rintaro Okamura <[email protected]> * ⚡ Add static Signed-off-by: Rintaro Okamura <[email protected]> * 🔥 Remove static flags Signed-off-by: Rintaro Okamura <[email protected]>
1 parent 6f3eb19 commit 466aaff

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ increments version by git log message contexts.
2323

2424
[semver workflow of this repository](https://github.com/rinx/gitwerk/blob/master/.github/workflows/semver.yml) is an example of this subcommand.
2525

26-
```
26+
```bash
2727
## when the latest tag is v0.0.1
2828
$ git commit -m "[patch] increment patch version"
2929
## the commit comment contains "[patch]"
@@ -64,7 +64,7 @@ $ gitwerk semver-auto
6464

6565
prints incremented version.
6666

67-
```
67+
```bash
6868
## when the latest tag is v0.0.1
6969

7070
$ gitwerk semver patch
@@ -81,7 +81,7 @@ v1.0.0
8181

8282
gitwerk supports to run user-defined scripts written in clojure (powered by [borkdude/sci](https://github.com/borkdude/sci)).
8383

84-
```
84+
```bash
8585
## can read stdin
8686
$ echo '(semver ctx ["patch"])' | gitwerk sci
8787
v0.0.2
@@ -107,6 +107,12 @@ Version not updated
107107
$ git commit --allow-empty -m "[patch] version updated"
108108
$ gitwerk sci examples/example2.clj
109109
Version updated: v0.0.3 -> v0.0.4
110+
111+
## http get/post using clj-http-lite.client
112+
$ echo '(-> (http/get "https://api.github.com/repos/rinx/gitwerk/issues") pprint)' | gitwerk sci
113+
114+
## parse json and convert to clj map
115+
$ echo '(-> (http/get "https://api.github.com/repos/rinx/gitwerk/issues") :body (json/read-value) pprint)' | gitwerk sci
110116
```
111117

112118
## License

src/gitwerk/command/sci.clj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
(:require
33
[clojure.spec.alpha :as spec]
44
[clojure.pprint :as pprint]
5+
[clojure.edn :as edn]
56
[sci.core :as sci]
6-
[gitwerk.internal.io :as internal.io]))
7+
[clj-http.lite.client :as http]
8+
[gitwerk.internal.io :as internal.io]
9+
[gitwerk.internal.json :as json]))
710

811
(def clj-primitives
912
{'println println
10-
'pprint pprint/pprint})
13+
'pprint pprint/pprint
14+
'json/read-value json/read-value
15+
'edn/read-string edn/read-string
16+
'env #(or (System/getenv %) "")
17+
'http/get http/get
18+
'http/post http/post})
1119

1220
(defn run-fn [sci-opts]
1321
(fn [ctx args]

0 commit comments

Comments
 (0)