 
 " (:summary (clojure.tools.cli/parse-opts nil cli-options))))
 
-(defn parse-args [args]
+(defn parse-args [cli-args]
   "Parse command line arguments.
 
   Prints help or error messages as needed.
 
   Returns the options if everything went as expected, or nil if the program
   should not proceed. Hence, can be used in a when-let."
-  (let [{:keys [options errors]} (clojure.tools.cli/parse-opts args cli-options)
+  (let [{args :options errors :errors}
+          (clojure.tools.cli/parse-opts cli-args cli-options)
         print-error? (not-empty errors)
-        print-help?  (or (not-empty errors) (:help options))
+        print-help?  (or (not-empty errors) (:help args))
         proceed?     (not (or print-error? print-help?))]
     (when print-error?
       (println "ERROR: Error when parsing command line arguments:\n "

    ; Note: as opposed to the vacation benchmark, we only support making
    ; reservations, not deleting customers or updating tables.
    (log "start reservation" (:id @reservation) "by worker" worker-id)
    (process-reservation-par reservation data options secondary-workers)
    (send master :done :reservation (:id @reservation))))

(def done? (promise))

(def master-waiting-behavior
  (behavior
    [n]
    [_done _key _id]
    ; _key is one of :reservation, :car, :flight, :room
    (if (= n 1)
      (do
        (log "done")
        #_(log-data data)
        (deliver done? true))
      (become :same (dec n)))))

(def master-initial-behavior
  (behavior
    [{:keys [n-workers n-secondary-workers n-reservations] :as options}]
    [_start]
    (let [{:keys [reservations cars flights rooms] :as data}
            (initialize-data options)

          secondary-workers
            (doall (map #(spawn reserve-relation-behavior % *actor*)
                        (range n-secondary-workers)))
            ; n-secondary-workers = 0 if version == :seq
          reservation-workers
            (doall (map #(spawn reservation-behavior
                          % *actor* secondary-workers data options)
                        (range n-workers)))
          expected-n-done-messages
            (case version
              :par (* n-reservations 4)
                   n-reservations)
          start-time
            (System/nanoTime)]
      #_(log-data data)
      (doseq [[worker reservation] (zip (cycle reservation-workers) reservations)]
        (send worker reservation))
      (become master-waiting-behavior start-time expected-n-done-messages))))

; MAIN

