-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.clj
58 lines (46 loc) · 1.83 KB
/
variables.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(ns info.setmy.environment.variables
"Environment variables functionality."
(:gen-class)
(:require [clojure.string :as str]
[info.setmy.string.operations :refer :all]))
(defn set-environment-variable
[variable-name variable-value]
(throw
(java.lang.UnsupportedOperationException. "Setting system environment variable is not implemented.")))
(defn get-environment-variable
[variable-name]
(System/getenv variable-name))
(defn delete-environment-variable
[variable-name]
(throw
(java.lang.UnsupportedOperationException. "Deleting system environment variable is not implemented.")))
(defn get-boolean-environment-variable
[variable-name]
(to-boolean (get-environment-variable (variable-name))))
(defn get-short-environment-variable
[variable-name]
(to-short (get-environment-variable (variable-name))))
(defn get-int-environment-variable
[variable-name]
(to-int (get-environment-variable (variable-name))))
(defn get-long-environment-variable
[variable-name]
(to-long (get-environment-variable (variable-name))))
(defn get-float-environment-variable
[variable-name]
(to-float (get-environment-variable (variable-name))))
(defn get-double-environment-variable
[variable-name]
(to-double (get-environment-variable (variable-name))))
(defn get-json-environment-variable
[variable-name]
(json-to-object (get-environment-variable (variable-name))))
(defn get-environment-variables-list
[variable-name & [parse-function]]
(if (nil? variable-name)
[]
(let [trimmed-list (remove empty?
(split-and-trim (nil-to-default (get-environment-variable variable-name))))]
(if (nil? parse-function)
trimmed-list
(map-indexed parse-function trimmed-list)))))