   (:require [clojure.string]
             [clojure.tools.cli]))
 
+; LOGGING
+
 (defn log [& args]
-  "Log the given arguments. This does nothing, but is overwritten in main if the
-  debug option is enabled."
+  "Log the given arguments. This does nothing, but is overwritten in parse-args
+  if the debug option is enabled."
   nil)
-
 (def logger (agent nil))
 (defn log-debug [& args]
   "Log the given arguments. This function is used when debugging is enabled."
   (send logger (fn [_] (apply println args))))
+
+; PARSE COMMAND LINE OPTIONS
 
 (def cli-options
   [["-n" "--customers N" "Number of customers"

   ["-d" "--debug" "Print debug information"]
   ["-h" "--help" "Print help information"]])

(def usage
  (str
"Usage: ./vacation2 [options]

Options:

" (:summary (clojure.tools.cli/parse-opts nil cli-options))))

(def customer-behavior
  (behavior

    (dosync
      (println "TODO"))))

; MAIN

(defn -main [& args]
  "Main function. `args` should be a list of command line arguments."
  (when-let [options (parse-args args)]
    (let [{:keys [reservations customers]} options
          reservations-per-customer (quot reservations customers)
          customer-actors
            (for [i (range customers)]
              (spawn customer-behavior))]
      (when (not= (rem reservations customers) 0)
        (println "WARNING: number of reservations is not divisible by number"
          "of customers. Using" reservations-per-customer "reservations per"
          "customer, so only" (* reservations-per-customer customers)
          "in total."))
      (doseq [c customer-actors]
        (dotimes [_i reservations-per-customer]
          (send c)))))
  (shutdown-agents))
