 (defn get-invoice-filenames []
   (filter is-json? (map get-io-file-name (file-seq (io/file (cwd))))))
 
+(defn read-all-invoices []
+  (map read-json (get-invoice-filenames)))
+
 (defn data []
-  (println (json/write-str (map read-json (get-invoice-filenames)))))
+  (println (json/write-str (read-all-invoices))))
+
+(defn options-to-filter [options]
+  (fn [invoice]
+    (every? (fn[key_](= (get options key_) (get invoice (name key_)))) (keys options))))
+
+(defn list_ [options]
+  (println (json/write-str (filter (options-to-filter options) (read-all-invoices)))))
 
 (defn -main [& args]
   (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]

    (case (first arguments)
      "create" (create options arguments)
      "data" (data)
      (exit 1 (usage summary)))))

        ""
        "  invadm create -c CURRENCY -r CLIENT -a AMOUNT [-f FILENAME] ID"
        "    Creates an invoice."
        ""
        "  invadm list {-c CURRENCY, -r CLIENT, -f FILENAME}"
        "    Lists invoices."
        ""
        "  invadm data"
        "    Dump all the data in a JSON array."]
