File tree Expand file tree Collapse file tree 2 files changed +36
-6
lines changed
Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Original file line number Diff line number Diff line change 1- (defproject mobdap " 0.1.0"
1+ (defproject mobdap " 0.1.0-alpha2 "
22 :description " Debug Adapter for MobDap"
33 :url " https://github.com/atomicptr/mobdap"
44 :license {:name " GPL-3.0-or-later" :url " https://www.gnu.org/licenses/gpl-3.0.en.html" }
55 :dependencies [[cheshire/cheshire " 6.0.0" ]
6+ [org.clojure/tools.cli " 1.1.230" ]
67 [clj-stacktrace " 0.2.8" ]
78 [com.taoensso/timbre " 6.7.1" ]
89 [org.clojure/clojure " 1.12.1" ]
Original file line number Diff line number Diff line change 11(ns mobdap.main
22 (:require
33 [clojure.java.io :as io]
4+ [clojure.tools.cli :refer [parse-opts]]
45 [mobdap.handler :as handler]
56 [taoensso.timbre :as log]
67 [taoensso.timbre.appenders.core :as appenders])
1112 (System/getenv " XDG_CACHE_HOME" )
1213 (str (io/file (System/getProperty " user.home" ) " .cache" ))))
1314
15+ (def cli-options
16+ [[" -v" " --version" " Show the installed version of mobdap" ]
17+ [" -h" " --help" " Show the help text" ]])
18+
19+ (defn- print-usage [result]
20+ (println " Usage:" )
21+ (println (str " \t " " mobdap [options]" ))
22+ (println )
23+ (println (:summary result)))
24+
1425(defn -main [& args]
15- (log/set-config!
16- {:level :info
17- :appenders {:spit (appenders/spit-appender {:fname (str (io/file (cache-dir ) " mobdap.log" ))})}})
18- (log/info " Started mobdap with arguments:" args)
19- (handler/run ))
26+ (let [res (parse-opts args cli-options)]
27+ (cond
28+ ; if we had errors
29+ (not-empty (:errors res)) (do (println " Error:" )
30+ (doseq [err (:errors res)]
31+ (println (str " \t " err)))
32+ (println )
33+ (print-usage res)
34+ (System/exit 1 ))
35+
36+ ; --help
37+ (get-in res [:options :help ]) (print-usage res)
38+
39+ ; --version
40+ (get-in res [:options :version ]) (println (System/getProperty " mobdap.version" ))
2041
42+ ; run the app
43+ :else
44+ (do
45+ (log/set-config!
46+ {:level :info
47+ :appenders {:spit (appenders/spit-appender {:fname (str (io/file (cache-dir ) " mobdap.log" ))})}})
48+ (log/info " Started mobdap with arguments:" args)
49+ (handler/run )))))
2150
You can’t perform that action at this time.
0 commit comments