 (ns puppetlabs.trapperkeeper.core
   (:require [clojure.tools.logging :as log]
-            [slingshot.slingshot :refer [try+ throw+]]
             [puppetlabs.kitchensink.core :refer [without-ns]]
             [puppetlabs.trapperkeeper.services :as services]
             [puppetlabs.trapperkeeper.app :as app]

  (let [quit (fn [status msg stream]
               (binding [*out* stream] (println msg) (flush))
               (System/exit status))]
    (try+
      (-> (or args '())
          (internal/parse-cli-args!)
          (run))
      (catch map? m
        (let [type (:kind m)]
          (if (keyword? type)
            (case (without-ns (:kind m))
              :cli-error (quit 1 (:msg m) *err*)
              :cli-help (quit 0 (:msg m) *out*)
              ;; By default let the throw below reraise the error
              nil)))
        (throw+))
      (finally
        (log/debug (i18n/trs "Finished TK main lifecycle, shutting down Clojure agent threads."))
        (shutdown-agents)))))

            [puppetlabs.trapperkeeper.plugins :as plugins]
            [schema.core :as schema]
            [puppetlabs.trapperkeeper.common :as common]
            [puppetlabs.i18n.core :as i18n])
  (:import
   (clojure.lang ExceptionInfo)))

(def #^{:macro true
        :doc "An alias for the `puppetlabs.trapperkeeper.services/service` macro
