Skip to content

Commit

Permalink
EDN does not work in CLJS - see #19
Browse files Browse the repository at this point in the history
  • Loading branch information
lenz committed Nov 16, 2018
1 parent 443b37f commit 72878e9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject cli-matic "0.2.2"
(defproject cli-matic "0.2.3"
:description "Compact [sub]command line parsing library, for Clojure"
:url "https://github.com/l3nz/cli-matic"
:license {:name "Eclipse Public License, v2"
Expand Down
11 changes: 10 additions & 1 deletion src/cli_matic/platform.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
BTW, in this NS, we avoid using Spec / Orchestra.
")
"
(:require [clojure.edn :as edn]))

(defn read-env
"Reads an environment variable.
Expand Down Expand Up @@ -56,3 +57,11 @@
(java.text.SimpleDateFormat. "yyyy-MM-dd") s)
(catch Throwable t
nil)))

(defn parseEdn
"
Decodes EDN through clojure.edn.
"
[edn-in]
(edn/read-string edn-in))

6 changes: 6 additions & 0 deletions src/cli_matic/platform.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@
[s]
nil)

(defn parseEdn
"
See https://stackoverflow.com/questions/44661385/how-do-i-read-an-edn-file-from-clojurescript-running-on-nodejs
"
[edn-in]
nil)
7 changes: 3 additions & 4 deletions src/cli_matic/presets.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"
(:require [clojure.string :as str]
[clojure.edn :as edn]
[cli-matic.optionals :as OPT]
[cli-matic.platform :as P]
))
Expand Down Expand Up @@ -33,12 +32,12 @@
"Decodes the value as an EDN structure."
[s]
;;(edn/read-string (if (string? s) s (str/join s)))
(edn/read-string s))
(P/parseEdn s))

(defn asDecodedEdnFile
"Decodes the contents of a file as a JSON object."
[filename]
(edn/read-string (asSingleString filename)))
(P/parseEdn (asSingleString filename)))

(defn asDecodedJsonValue
"Decodes the value as a JSON object."
Expand Down Expand Up @@ -68,7 +67,7 @@

(defn asKeyword
[s]
(-> s replace-double-colon edn/read-string keyword))
(-> s replace-double-colon P/parseEdn keyword))

;; Remember to add these to
;; ::S/type
Expand Down

0 comments on commit 72878e9

Please sign in to comment.