               (str (apply str (repeat (- c 1) " ")) "^")))
       (insta/transform {child f} result))))
 
-(defn nml-uniq [values]
-  (loop [head (first values) tail (rest values) tree []]
-    (if (nil? head)
-      tree
-      (let [name #(nml-name (second %))
-            copy  (some #(= (name head) (name %)) tail)]
-        (recur (first tail) (rest tail) (into tree (if copy [] [head])))))))
-
-;; cli
-
-(defn assoc-get [m k v]
-  (let [gets (:get m [])]
-    (assoc m :get (into gets [v]))))
-
-(defn assoc-set [m k v]
-  (let [sets (:set m [])]
-    (assoc m :set (into sets [v]))))
-
-(defn parse-get [x]
-  (string/split x #":" 2))
-
-(defn parse-set [x]
-  (let [[nml+key val] (string/split x #"=" 2)
-        [nml key] (parse-get nml+key)]
-    [nml key val]))
-
-(def cliopts
-  [["-g" "--get n:k"   "Get value of key 'k' in namelist 'n'"         :assoc-fn assoc-get :parse-fn parse-get]
-   ["-h" "--help"      "Show usage information"                                                              ]
-   ["-i" "--in-place"  "Edit namelist file in place"                                                         ]
-   ["-n" "--no-prefix" "Report values without 'namelist:key=' prefix"                                        ]
-   ["-s" "--set n:k=v" "Set value of key 'k' in namelist 'n' to 'v'"  :assoc-fn assoc-set :parse-fn parse-set]
-   ["-v" "--version"   "Show version information"                                                            ]])
-  
 ;; main
-
-(defn usage [summary]
-  (doseq [x [""
-             "Usage: nml [options] file"
-             ""
-             "Options:"
-             ""
-             summary
-             ""]]
-    (println x))
-  (System/exit 0))
 
 (defn -main [& args]
   (alter-var-root #'*read-eval* (constantly false))


(def version "0.1")


;; utility defns

(defn fail [& lines]
  (binding [*out* *err*]
    (doseq [line lines]
      (println line))
    (System/exit 1)))

(defn warn [& lines]
  (binding [*out* *err*]
    (doseq [line lines]
      (println (str "WARNING: " line)))))

;; nml defns

(defn nml-add [tree parent child match proxy]
  (let [missing  (fn [children] (not-any? #(= (nml-name %) match) children))
        vnew    #(parse proxy :start child)
        f        (fn [& children] (if (missing children)

  (:require [clojure.tools.cli :as cli   ])
  (:gen-class))

(declare nml-get nml-name nml-set nml-str)

; defs

