|
48 | 48 | "/usr/local/bin:" ;; homebrew
|
49 | 49 | (get sys-env "PATH"))}))))
|
50 | 50 |
|
51 |
| -(defn exit [status & [msg]] |
52 |
| - (when msg (println msg)) |
53 |
| - (when-not dev? (misc/exit status))) |
| 51 | +(defn exit |
| 52 | + ([status] (exit [status nil])) |
| 53 | + ([status msg] |
| 54 | + (when msg (println msg)) |
| 55 | + (when-not (env :is-dev) (System/exit status)))) |
54 | 56 |
|
55 | 57 | ;; paths
|
56 | 58 | (defn json-config-file-path
|
|
82 | 84 | (let [{:keys [applications devices keyboard-type input-sources tos froms modifiers layers simlayers ;; raws
|
83 | 85 | main simlayer-threshold templates profiles]} conf]
|
84 | 86 | (if (nil? profiles)
|
85 |
| - (profiles/parse-profiles (:profiles d/conf-data)) |
| 87 | + (profiles/parse-profiles (:profiles @d/conf-data)) |
86 | 88 | (profiles/parse-profiles profiles))
|
87 | 89 | (update-static-conf :applications applications)
|
88 | 90 | (update-static-conf :devices devices)
|
|
185 | 187 | [["-h" "--help"]
|
186 | 188 | ["-V" "--version"]
|
187 | 189 | ["-l" "--log"]
|
| 190 | + [nil "--where-is-my-config"] |
188 | 191 | ["-c" "--config PATH" "Config PATH"
|
189 | 192 | :parse-fn (comp fs/file fs/expand-home)
|
190 | 193 | :validate [(fn [path]
|
|
209 | 212 | {:action "exit-with-message"
|
210 | 213 | :ok? true
|
211 | 214 | :exit-message (help-message summary)}
|
| 215 | + (:where-is-my-config options) |
| 216 | + {:action "show-config-path" |
| 217 | + :ok? true} |
212 | 218 | ;; version
|
213 | 219 | (:version options)
|
214 | 220 | {:action "exit-with-message"
|
|
237 | 243 | [& args]
|
238 | 244 | (let [{:keys [action ;; options
|
239 | 245 | exit-message ok? config dry-run dry-run-all]} (validate-args args)]
|
240 |
| - (when exit-message |
241 |
| - (case action |
242 |
| - "run" (do (parse (or (and config (-> config fs/expand-home fs/file .getPath)) (edn-config-file-path)) dry-run dry-run-all) |
243 |
| - (exit (if ok? 0 1) exit-message)) |
244 |
| - "log" (do (open-log-file) |
245 |
| - (exit 0)) |
246 |
| - "exit-with-message" (exit (if ok? 0 1) exit-message) |
247 |
| - "errors" (exit (if ok? 0 1) exit-message) |
248 |
| - "default" (exit (if ok? 0 1) exit-message))))) |
| 246 | + (case action |
| 247 | + "run" (do (parse (or config (edn-config-file-path)) dry-run dry-run-all) |
| 248 | + (exit (if ok? 0 1) exit-message)) |
| 249 | + "show-config-path" (exit 0 (or config (edn-config-file-path))) |
| 250 | + "log" (do (open-log-file) (exit 0)) |
| 251 | + "exit-with-message" (exit (if ok? 0 1) exit-message) |
| 252 | + "errors" (exit (if ok? 0 1) exit-message) |
| 253 | + "default" (exit (if ok? 0 1) exit-message)))) |
249 | 254 |
|
250 |
| -;; (when-not dev? (apply -main *command-line-args*)) |
| 255 | +(when-not dev? (apply -main *command-line-args*)) |
251 | 256 |
|
252 | 257 | (comment
|
253 | 258 | (-main)
|
|
256 | 261 | (-main "-l")
|
257 | 262 | (-main "--log")
|
258 | 263 | (-main "--config" "./")
|
| 264 | + (-main "--where-is-my-config") |
259 | 265 | (-main "-c" "./")
|
260 | 266 | (-main "-dc" "./")
|
261 | 267 | (-main "-dc" "~/.config/karabiner.edn")
|
262 | 268 | (-main "-dc" "~/.config/karabiner.test.edn")
|
| 269 | + (-main "-c" "~/.nixpkgs/modules/yqrashawn/home-manager/dotfiles/karabiner.edn") |
263 | 270 | (-main "-d")
|
264 | 271 | (-main "-V")
|
265 | 272 | (-main "--version"))
|
0 commit comments