<commit_before>(ns statuses.server
  (:require [ring.adapter.jetty :refer [run-jetty]]
            [ring.middleware.content-type :refer [wrap-content-type]]
            [ring.middleware.not-modified :refer [wrap-not-modified]]
            [ring.middleware.params :refer [wrap-params]]
            [ring.middleware.reload :refer [wrap-reload]]
            [ring.middleware.resource :refer [wrap-resource]]
            [clojure.tools.cli :refer [parse-opts]]
            [ring.middleware.stacktrace :refer [wrap-stacktrace]]
            [statuses.backend.persistence :as persistence]
            [statuses.configuration :as cfg :refer [config]]
            [statuses.routing :as main])
  (:gen-class))

(def app
  (-> main/app-routes
      wrap-params
      (wrap-resource "public")
      wrap-content-type
      wrap-not-modified
      wrap-stacktrace))


(def cli-options
  [["-p" "--port PORT" "Port number" :parse-fn #(Integer/parseInt %)]
  ["-h" "--host HOST" "Hostname"]
  ["-c" "--conf ConfigurationFile" "The Location of the Configuration File"]])

(defn -main [& args]
  (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
    (cfg/init! (or (:conf options) "config.clj"))
    (println "Configuration: " (config))
    (println "CLI Options: " (str options))
    (persistence/init! (config :database-path) (config :save-interval))
    
    (println "Starting server on host" (or (:host options) (config :host))
             "port" (or (:port options) (config :http-port))
             "in mode" (config :run-mode))
    (run-jetty
      (if (= (config :run-mode) :dev)
        (wrap-reload app)
        app)
      {:host (or (:host options) (config :host))
       :port (or (:port options) (config :http-port))
       :join? false}))
  )

<commit_msg>Use first argument as configuration file fallback<commit_after>(ns statuses.server
  (:require [ring.adapter.jetty :refer [run-jetty]]
            [ring.middleware.content-type :refer [wrap-content-type]]
            [ring.middleware.not-modified :refer [wrap-not-modified]]
            [ring.middleware.params :refer [wrap-params]]
            [ring.middleware.reload :refer [wrap-reload]]
            [ring.middleware.resource :refer [wrap-resource]]
            [clojure.tools.cli :refer [parse-opts]]
            [ring.middleware.stacktrace :refer [wrap-stacktrace]]
            [statuses.backend.persistence :as persistence]
            [statuses.configuration :as cfg :refer [config]]
            [statuses.routing :as main])
  (:gen-class))

(def app
  (-> main/app-routes
      wrap-params
      (wrap-resource "public")
      wrap-content-type
      wrap-not-modified
      wrap-stacktrace))


(def cli-options
  [["-p" "--port PORT" "Port number" :parse-fn #(Integer/parseInt %)]
   ["-h" "--host HOST" "Hostname"]
   ["-c" "--conf ConfigurationFile" "The Location of the Configuration File"]])

(defn -main [& args]
  (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
    (println "CLI Options: " (str options))
    (cfg/init! (or (:conf options) (first arguments) "config.clj"))
    (println "Configuration: " (config))
    (persistence/init! (config :database-path) (config :save-interval))
    (println "Starting server on host" (or (:host options) (config :host))
             "port" (or (:port options) (config :http-port))
             "in mode" (config :run-mode))
    (run-jetty
      (if (= (config :run-mode) :dev)
        (wrap-reload app)
        app)
      {:host (or (:host options) (config :host))
       :port (or (:port options) (config :http-port))
       :join? false})))


{'fraction_non_alphanumeric': 0.15865118850193477, 'fraction_numerical': 0.0, 'mean_word_length': 2.7041965199590585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2608314', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1136, 'n_words': 292}