     (when (re-find (re-pattern catalog-pattern) path)
       (println (format "Importing catalog from archive entry '%s'" path))
       ;; NOTE: these submissions are async and we have no guarantee that they
-      ;;   will succeed.  We might want to add something at the end of the import
+      ;;   will succeed. We might want to add something at the end of the import
       ;;   that polls puppetdb until the command queue is empty, then does a
       ;;   query to the /nodes endpoint and shows the set difference between
       ;;   the list of nodes that we submitted and the output of that query

;; ## Import utility
;;
;; This is a command-line tool for importing data into PuppetDB.  It expects
;; as input a tarball generated by the PuppetDB `export` command-line tool.

(ns com.puppetlabs.puppetdb.cli.import


(def cli-description "Import PuppetDB catalog data from a backup file")

(defn check-import
  "Checks for the existence of a file. If filename exists, does nothing.
  If filename does not exist print a message and execute f"
  [filename f]
  (if (fs/exists? filename)
    true 
    (do 
      (println (format "Import from %s failed. File not found." filename)) 
      (f))))

(defn parse-metadata
  "Parses the export metadata file to determine, e.g., what versions of the
  commands should be used during import."
  [tarball]
  {:post [(map? %)
          (contains? % :command-versions)]}
  (check-import tarball #(System/exit 0))
  (let [metadata-path (.getPath (io/file export-root-dir export-metadata-file-name))]
    (with-open [tar-reader (archive/tarball-reader tarball)]
      (when-not (archive/find-entry tar-reader metadata-path)
