   [idquery]
   (if (number? (read-string idquery))
     (println (get-info idquery))
-    (let [results (-> idquery aur-search results->ip-map)
-          id  (do (print "Enter the Package ID to install : ")
-                  (read-string (read-line)))]
-      (if (contains? results id)
-        (install (get results id))
-        (println "Package ID not found!"))
-      )))
+    (let [results (-> idquery aur-search results->ip-map)]
+      (if (not-empty results)
+        (let [id  (do (print "Enter the Package ID to install : ")
+                      (flush)
+                      (read-string (read-line)))]
+          (if (contains? results id)
+            (install (get results id))
+            (println "Package ID not found!"))))
+       )))
 
 (defn -main
   "

  [filename filepath outdir]
  (let [target (str outdir
                    "/"
                    (clojure.string/replace filename #"\.gz$" ""))]
    (println "Extracting " filepath "into" target)
    (compr/gunzip filepath target)
    (println "Extracting " target "into" outdir)
    (compr/untar target outdir)
    (println "Deleting " target)
    (fs/delete target)
))

(defn install
  [pkg]
  (do
    (println pkg)
    (let [[f bytes] (get-pkg pkg)
           filepath (str pkg-dir "/" f)
           target (clojure.string/replace filepath #"\.tar\.gz$" "/")]
      (println filepath)
      (save-file filepath bytes)
      (extract f filepath pkg-dir))))

(defn aur-search
  [query]

  (:use aurman.api)
  (:require [me.raynes.fs :as fs]
            [me.raynes.fs.compression :as compr])
  (:use [clojure.java.shell :only [sh with-sh-dir]]))

(def pkg-dir "/tmp")

