                           ssh-options
                           [(ssh-client host user) cmd]))))
 
-(defn rsync [host user cluster src dst]
-  (let [rsync-options (find-client-options host user cluster :rsync-options)]
+(defn rsync 
+  "Rsync local files to remote machine's files,for example:
+     (deftask :deploy \"scp files to remote machines\" []
+    (rsync \"src/\" \":/home/login\"))
+
+    Valid options:
+    :rsync-options  -- rsync options string
+  "
+  {:arglists '([src dst & opts])}
+  [host user cluster src dst & opts]
+  (let [m (apply hash-map opts)
+        rsync-options (or (:rsync-options m) (find-client-options host user cluster :rsync-options))]
     (log-with-tag host "rsync" rsync-options (str src " ==>" dst))
     (exec host
           user

(def ^:private bash-redbold "\033[1;31m")
(def ^:private bash-greenbold "\033[1;32m")

(defmacro cli-bash-bold [& content]
  `(if *enable-color*
     (str bash-bold ~@content bash-reset)
     (str ~@content)))

(defmacro cli-bash-redbold [& content]
  `(if *enable-color*
     (str bash-redbold ~@content bash-reset)
     (str ~@content)))

(defmacro cli-bash-greenbold [& content]
  `(if *enable-color*
     (str bash-greenbold ~@content bash-reset)
     (str ~@content)))


(defstruct ExecProcess  :stdout :stderr :status)

(defn gen-log [host tag content]
  (str (cli-bash-redbold host ":")
       (cli-bash-greenbold tag ": ")
       (join " " content)))

(defn log-with-tag [host tag & content]
  (if (and *enable-logging* (not (blank? (join " " content))))
    (println (gen-log host tag content))))

(defn- not-nil? [obj]
  (not (nil? obj)))

(defn  ^:dynamic  exec [host user cmdcol]
  (let [rt (apply sh (filter not-nil? cmdcol))
        status (:exit rt)
        stdout (:out rt)
        stderr (:err rt)

(defn call
  "Call other tasks in deftask,for example:
     (call :ps \"java\")"
  {:arglists '([task & args])}
  [host user cluster task & args]
  (apply
   (task @tasks)
   host user cluster args))

(defn exists?
  "Check if a file or directory is exists"
  {:arglists '([file])}
  [host user cluster file]
  (zero? (:status (ssh host user cluster (str "test -e " file)))))


(defn- unquote-cluster [args]
