        plugins)
       (info "There are no plugins configured to load"))))
 
+(comment
+  (load-plugins)
+  )
+
 (defn load-all
   "Load all plugins, observers, and commands.
 

(ns yetibot.core.loader
  (:require
   [taoensso.timbre :refer [debug info warn error]]
   [yetibot.core.config :refer [get-config]]
   [clojure.spec.alpha :as s]
   [yetibot.core.spec :as yspec]

   ;; yetibot.core.commands.*
   ;; yetibot-pluginname.commands.*
   #"^yetibot(\S*)\.(core\.)?commands.*"
   all-command-plugins-regex
   ])

(comment
  (find-namespaces
    (first yetibot-command-namespaces)))

; mycompany.plugins.observers.*
(def all-observer-plugins-regex #"^.*plugins\.observers.*")

(def yetibot-observer-namespaces
  [#"^yetibot\.(core\.)?observers.*"
   all-observer-plugins-regex
   ])

(comment
  (find-namespaces
   (first yetibot-observer-namespaces)))

(def yetibot-all-namespaces
  ;; to mimic previous return type of (merge), using (list) vs plain old vector
  ;; in theory, it should not matter (lazy vs non-lazy) -- but don't want to risk it
  (list all-command-plugins-regex
        all-observer-plugins-regex
        #"^yetibot\.(.(?!(core)))*"    ; with a negative lookahead assertion
  ))

(comment
  yetibot-all-namespaces
  )

(defn load-ns [arg]
  (debug "Loading" arg)
  (try
    (require arg)
    arg
    (catch Exception e
      (warn "WARNING: problem requiring" arg "hook:" (.getMessage e))
      (st/print-stack-trace (st/root-cause e) 15))))

(comment
  (load-ns 'yetibot.core.commands.help)
  (load-ns 'i.will.fail)
  )

(defn find-and-load-namespaces
  "Find namespaces matching ns-patterns: a seq of regex patterns. Load the matching
   namespaces and return the seq of matched namespaces."
  [ns-patterns]
  (let [nss (flatten (map find-namespaces ns-patterns))
        nss-count-output (str (count nss) " namespaces matching " ns-patterns)]
    (info "☐ Loading" nss-count-output)
    (doseq [n nss] (load-ns n))
    (info "☑ Loaded" nss-count-output)
    nss))

(comment
  (find-and-load-namespaces '(#"yetibot\.core\.commands\.help"))
  )

(defn load-commands []
  (find-and-load-namespaces yetibot-command-namespaces))

(comment
  (load-commands)
  )

(defn load-observers []
  (find-and-load-namespaces yetibot-observer-namespaces))
