 ;; main
 
 (defn -main [& args]
+
   (alter-var-root #'*read-eval* (constantly false))
+
+  ;; bindings
+
   (let [{:keys [options arguments summary]} (cli/parse-opts args cliopts)
         gets (:get options)
         sets (:set options)
-        in   (or (:in  options) *in* )
-        out  (or (:out options) *out*)
-        src  (or (:in options) "stdin")]
-    (if (not-empty arguments) (fail (str "Unexpected argument '" (first arguments) "'.")))
+        edit (:edit options)
+        in   (or edit (:in options) *in*)
+        out  (or edit (:out options) *out*)
+        src  (or edit (:in options) "stdin")]
+
+    ;; error checking
+
+    (if (not-empty arguments) (fail (str "Unexpected argument '" (first arguments) "'")))
     (if (:help options) (usage summary))
     (if (:version options) (do (println version) (System/exit 0)))
     (if (and gets sets) (fail (msgs :get+set)))
+    (if (and gets edit) (fail (msgs :get+edit)))
+    (if (and edit (:in options)) (fail (msgs :edit+in)))
+    (if (and edit (:out options)) (fail (msgs :edit+out)))
     (if (and gets (:format options)) (fail (msgs :get+format)))
     (if (and sets (:no-prefix options)) (fail (msgs :set+no-prefix)))
     (if (and (:create options) (:in options)) (fail (msgs :create+in)))
+
+    ;; read -> parse -> [modify] -> output
+
     (let [fmt (let [f (:format options)] (if f (formats f) fmt-namelist))
           m   (nml-map (if (:create options) "" (read-file in)) src)]
       (cond gets  (nml-out out (nml-gets m gets (:no-prefix options)))

    (println (string/trim s))
    (try (spit out s)
         (catch Exception e
           (fail (str "Could not write to '" out "'."))))))

(defn- nml-parse [s start src]
  (let [result (parse s :start start)]

    (if (empty? s)
      m
      (let [[nml key val] (first s)]
        (if (nil? val) (fail (str "No value supplied for key '" key "'")))
        (recur (nml-set m nml key val) (rest s))))))

(defn- nml-str [x]
