Skip to content

Commit 2f44f97

Browse files
committed
wip: printing workspaces as json
Had to remove some logging and use print - this is to get some jq-able data out via babashka in my current hyprland config.
1 parent 916ff1f commit 2f44f97

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

src/clawe/cli.clj

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns clawe.cli
22
(:require
33
[clojure.string :as string]
4+
[cheshire.core :as json]
45
[clawe.config :as clawe.config]))
56

67
;; TODO support ops like these with smth like -j
@@ -13,27 +14,39 @@
1314
(defn workspace-def [{:as _opts :keys [title]}]
1415
(clawe.config/workspace-def title))
1516

17+
(defn workspace-def-j [opts]
18+
(->>
19+
(workspace-def opts)
20+
(json/generate-string)
21+
println))
22+
1623
(defn workspace-dir [opts]
17-
(-> opts workspace-def :workspace/directory))
24+
(-> opts workspace-def :workspace/directory
25+
println))
1826

1927
(defn preferred-index [opts]
20-
(-> opts workspace-def :workspace/preferred-index))
28+
(-> opts workspace-def :workspace/preferred-index
29+
println))
2130

2231
(defn git-status [opts]
23-
(-> opts workspace-def :git/status))
32+
(-> opts workspace-def :git/status
33+
println))
2434

2535
(defn repo-dirs [opts]
2636
(->>
2737
(clawe.config/workspace-defs)
28-
(map (fn [[k def]] [k (:workspace/directory def)]))))
38+
(map (fn [[k def]] [k (:workspace/directory def)]))
39+
println))
2940

3041
(defn my-repo-dirs [opts]
3142
(->>
3243
(clawe.config/workspace-defs)
3344
(filter (comp :workspace/directory second))
3445
(filter (fn [[_ def]] (string/includes? (:workspace/directory def) "russmatney")))
3546
(map (fn [[k def]] [k (:workspace/directory def)]))
36-
(map str)
37-
(string/join "\n")
38-
;; (into {})
47+
;; (map str)
48+
;; (string/join "\n")
49+
(into {})
50+
(json/generate-string)
51+
println
3952
))

src/clawe/config.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[timer :as timer]))
1313

1414

15-
(timer/print-since "clawe.config ns loading")
15+
;; (timer/print-since "clawe.config ns loading")
1616

1717

1818
(def clawe-config-path ".config/clawe/clawe.edn")
@@ -36,12 +36,12 @@
3636
(assoc :home-dir (str (fs/home)))
3737
(->> ;; local should overwrite global
3838
(merge (read-config clawe-local-config-path))))]
39-
(timer/print-since "parsed and returning clawe config")
39+
;; (timer/print-since "parsed and returning clawe config")
4040
conf))
4141

4242
(defsys ^:dynamic *config*
4343
:start
44-
(timer/print-since "starting clawe.config system")
44+
;; (timer/print-since "starting clawe.config system")
4545
(atom (->config)))
4646

4747
(declare write-config)

src/timer.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
(reset! last-t now)
1212
(println "|" (when old-last (- now old-last)) "\t|" (- now @start-t) "\t|" line))))
1313

14-
(print-since "timer ns loaded")
14+
;; (print-since "timer ns loaded")

0 commit comments

Comments
 (0)