          :default                        [s]))
       flatten))
 
-(defn ^:private generate-spec
+(defn- generate-spec
   [raw-spec]
   (let [[switches raw-spec] (split-with #(and (string? %) (opt? %)) raw-spec)
         [docs raw-spec]     (split-with string? raw-spec)

      (cl-format true "~{ ~vA  ~vA  ~vA ~}" v)
      (prn))))

(defn ^:private name-for [k]
  (replace k #"^--no-|^--\[no-\]|^--|^-" ""))

(defn ^:private flag-for [^String v]
  (not (.startsWith v "--no-")))

(defn ^:private opt? [^String x]
  (.startsWith x "-"))

(defn ^:private flag? [^String x]
  (.startsWith x "--[no-]"))

(defn ^:private end-of-args? [x]
  (= "--" x))

(defn ^:private spec-for
  [arg specs]
  (->> specs
       (filter (fn [s]

                     (contains? switches arg))))
       first))

(defn- default-values-for
  [specs]
  (into {} (for [s specs] [(s :name) (s :default)])))

(defn- apply-specs
  [specs args]
  (loop [options    (default-values-for specs)
         extra-args []
