Moved print-usage out into support.
This commit is contained in:
parent
2ec8f4a928
commit
80860a264e
|
@ -2,6 +2,7 @@
|
||||||
:author "Simon Brooke"}
|
:author "Simon Brooke"}
|
||||||
adl.main
|
adl.main
|
||||||
(:require [adl-support.utils :refer :all]
|
(:require [adl-support.utils :refer :all]
|
||||||
|
[adl-support.print-usage :refer [print-usage]]
|
||||||
[adl.to-hugsql-queries :as h]
|
[adl.to-hugsql-queries :as h]
|
||||||
[adl.to-json-routes :as j]
|
[adl.to-json-routes :as j]
|
||||||
[adl.to-psql :as p]
|
[adl.to-psql :as p]
|
||||||
|
@ -52,43 +53,13 @@
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
(defn- doc-part
|
(defn usage [parsed-options]
|
||||||
"An `option` in cli-options comprises a sequence of strings followed by
|
"Show a usage message. `parsed-options` should be options as
|
||||||
keyword/value pairs. Return all the strings before the first keyword."
|
parsed by [clojure.tools.cli](https://github.com/clojure/tools.cli)"
|
||||||
[option]
|
(print-usage
|
||||||
(if
|
"adl"
|
||||||
(keyword? (first option)) nil
|
parsed-options
|
||||||
(cons (first option) (doc-part (rest option)))))
|
{"adl-file" "An XML file conforming to the ADL DTD"}))
|
||||||
|
|
||||||
(defn map-part
|
|
||||||
"An `option` in cli-options comprises a sequence of strings followed by
|
|
||||||
keyword/value pairs. Return the keyword/value pairs as a map."
|
|
||||||
[option]
|
|
||||||
(cond
|
|
||||||
(empty? option) nil
|
|
||||||
(keyword? (first option)) (apply hash-map option)
|
|
||||||
true
|
|
||||||
(map-part (rest option))))
|
|
||||||
|
|
||||||
(defn print-usage []
|
|
||||||
(println
|
|
||||||
(join
|
|
||||||
"\n"
|
|
||||||
(flatten
|
|
||||||
(list
|
|
||||||
(join
|
|
||||||
(list
|
|
||||||
"Usage: java -jar adl-"
|
|
||||||
(or (System/getProperty "adl.version") "[VERSION]")
|
|
||||||
"-SNAPSHOT-standalone.jar -options [adl-file]"))
|
|
||||||
"where options include:"
|
|
||||||
(map
|
|
||||||
#(let
|
|
||||||
[doc-part (doc-part %)
|
|
||||||
default (:default (map-part %))
|
|
||||||
default-string (if default (str "; (default: " default ")"))]
|
|
||||||
(str "\t" (join ", " (butlast doc-part)) ": " (last doc-part) default-string))
|
|
||||||
cli-options))))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
|
@ -97,16 +68,16 @@
|
||||||
(let [options (parse-opts args cli-options)]
|
(let [options (parse-opts args cli-options)]
|
||||||
(cond
|
(cond
|
||||||
(empty? args)
|
(empty? args)
|
||||||
(print-usage)
|
(usage options)
|
||||||
(not (empty? (:errors options)))
|
(not (empty? (:errors options)))
|
||||||
(do
|
(do
|
||||||
(doall
|
(doall
|
||||||
(map
|
(map
|
||||||
println
|
println
|
||||||
(:errors options)))
|
(:errors options)))
|
||||||
(print-usage))
|
(usage options))
|
||||||
(-> options :options :help)
|
(-> options :options :help)
|
||||||
(print-usage)
|
(usage options)
|
||||||
true
|
true
|
||||||
(do
|
(do
|
||||||
(let [p (:path (:options options))
|
(let [p (:path (:options options))
|
||||||
|
|
|
@ -587,8 +587,8 @@
|
||||||
:field
|
:field
|
||||||
#(= "text-area" (widget-type (property-for-field % entity) application)))
|
#(= "text-area" (widget-type (property-for-field % entity) application)))
|
||||||
"
|
"
|
||||||
{% script \"js/lib/node_modules/simplemde/dist/simplemde.min.js\" %}
|
{% script \"/js/lib/node_modules/simplemde/dist/simplemde.min.js\" %}
|
||||||
{% style \"js/lib/node_modules/simplemde/dist/simplemde.min.css\" %}")
|
{% style \"/js/lib/node_modules/simplemde/dist/simplemde.min.css\" %}")
|
||||||
(if
|
(if
|
||||||
(child-with-tag
|
(child-with-tag
|
||||||
form
|
form
|
||||||
|
|
Loading…
Reference in a new issue