File tree 2 files changed +22
-2
lines changed
2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change
1
+ language : clojure
Original file line number Diff line number Diff line change 1
1
(ns jlog.core
2
2
(:require [clojure.string :as str])
3
+ (:require [clojure.java.shell :only [sh]])
3
4
(:gen-class ))
4
5
6
+ (use '[clojure.java.shell :only [sh]])
7
+
5
8
(defn has-length?
6
9
" Checks if a list or string is of length n."
7
10
[args-list n]
37
40
(str/replace timelog " h" " h " )
38
41
timelog)))
39
42
43
+ (defn jar-path
44
+ " utility function to get the jar path without the jar file."
45
+ [& [ns ]]
46
+ (str/replace (-> (or ns (class *ns*))
47
+ .getProtectionDomain .getCodeSource .getLocation .getPath) #"[^/]+$" " " ))
48
+
49
+ (def jira-issue
50
+ (future
51
+ (let [out (:out (sh " hg" " branch" ))]
52
+ (if-not (str/blank? out)
53
+ (re-find #"[a-zA-Z]{3,4}-\d {1,4}" out)
54
+ (throw (Exception. " Cannot retrieve your current branch. Make sure you are in a repository's." ))))))
55
+
40
56
(defn -main [& args]
41
57
(if (valid-jlog-args-list? (get-two-args args))
42
- (spit " jlog.txt" (str (.format (java.text.SimpleDateFormat. " MM/dd/yyyy" ) (new java.util.Date)) " --- " (space-hrs&mins (second args)) " \n " ) :append true )
43
- (println " Invalid syntax. Run jlog with 'jlog -t 1h'" )))
58
+ (spit (str (jar-path ) " jlog.txt" ) (str @jira-issue " --- " (.format (java.text.SimpleDateFormat. " MM/dd/yyyy" ) (new java.util.Date)) " --- " (space-hrs&mins (second args)) " \n " ) :append true )
59
+ (println " Invalid syntax. Run jlog with 'jlog -t 1h'" ))
60
+ )
61
+
62
+
You can’t perform that action at this time.
0 commit comments