Skip to content

Commit 09615e1

Browse files
committed
refactor if statements for jlog function
nested ifs in clojure are hard to understand because of the implicit else embedded in each if statement
1 parent d544191 commit 09615e1

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/jlog/core.clj

+4-5
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,14 @@
7272
(defn jlog
7373
"Appends a worklog to the worklogs file. This is the jlog main function."
7474
[arg1 arg2 message]
75-
(if (= arg1 "-b")
76-
(if (valid-jlog-time? arg2)
75+
(cond
76+
(= arg1 "-b") (if (valid-jlog-time? arg2)
7777
(spit-log arg2 @(get-jira-issue) message)
7878
(throw (Exception. "Invalid timelog format provided.")))
79-
(if (valid-jlog-time? arg1)
80-
(if (valid-jira-issue? arg2)
79+
(valid-jlog-time? arg1) (if (valid-jira-issue? arg2)
8180
(spit-log arg1 (upper-case arg2) message)
8281
(throw (Exception. "Invalid Jira issue key format provided.")))
83-
(throw (Exception. "Invalid timelog format provided.")))))
82+
:else (throw (Exception. "Invalid timelog format provided."))))
8483

8584
(defn print-help
8685
"Prints the possible jlog commands to the console."
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Leiningen
2-
#Thu Jun 20 11:14:17 EDT 2019
2+
#Sat Jun 22 10:29:36 EDT 2019
33
version=0.1.0-SNAPSHOT
4-
revision=0ce5185f96c1bcb421eb86ecba0d9f9b4db27bc8
4+
revision=d54419115067f3bd8ab705ad69d62847ea290718
55
groupId=jlog
66
artifactId=jlog
83 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)