Skip to content

Commit

Permalink
Add support for reporting version
Browse files Browse the repository at this point in the history
  • Loading branch information
justone committed Jun 13, 2020
1 parent 1bc43a2 commit 4d83875
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions resources/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0-SNAPSHOT
1 change: 1 addition & 0 deletions scripts/compile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $NATIVE_IMAGE \
-H:Name=$app_name \
-H:+ReportExceptionStackTraces \
-H:ReflectionConfigurationFiles=reflection.json \
-H:IncludeResources=VERSION \
--initialize-at-build-time \
--report-unsupported-elements-at-runtime \
--verbose \
Expand Down
4 changes: 2 additions & 2 deletions src/brisk/lib/opts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
(defn format-help
[progname help parsed errors]
(let [{:keys [summary]} parsed
{:keys [message exit]} errors]
{:help (format help-fmt progname (or message help) summary)
{:keys [message plain exit]} errors]
{:help (if plain message (format help-fmt progname (or message help) summary))
:exit exit}))

(defn print-and-exit
Expand Down
7 changes: 7 additions & 0 deletions src/brisk/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require
[clojure.edn :as edn]
[clojure.java.io :as io]
[clojure.string :as string]
[clojure.tools.cli :refer [parse-opts]]

[taoensso.nippy :as nippy]
Expand Down Expand Up @@ -65,6 +66,7 @@
["-t" "--thaw" "Thaw mode"]
["-i" "--input FILENAME" "Input file"]
["-o" "--output FILENAME" "Output file"]
["-v" "--version" "Print version"]
])

(def help
Expand All @@ -81,6 +83,11 @@
(or (opts/find-errors parsed)
(let [{:keys [options]} parsed]
(cond
(:version options)
{:message (string/trim (slurp (io/resource "VERSION")))
:plain true
:exit 0}

(and (not (:thaw options)) (not (:freeze options)))
{:exit 1}))))

Expand Down

0 comments on commit 4d83875

Please sign in to comment.