Commit f230caf7 authored by Jonathan Poalses's avatar Jonathan Poalses

Initial project scaffolding added

parent 18c63815
/target
/classes
/checkouts
profiles.clj
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
/.prepl-port
.hgignore
.hg/
.idea/
*.iml
.clj-kondo
(defproject poalses.jonathan/dialect "0.0.1"
:description "A handcrafted dialect detector for CS major project"
:url "https://git.ysjcs.net:8888/jonathan.poalses/major-project-handcrafted"
:scm {:name "git"
:url "https://git.ysjcs.net:8888/jonathan.poalses/major-project-handcrafted.git"}
:pom-addition (:developers
[:developer
[:id "jonathan.poalses"]
[:name "Jonathan Poalses"]
[:url "https://ysjcs.net/~jonathan.poalses/"]
[:roles
[:role "developer"]
[:role "maintainer"]]])
:dependencies [[org.clojure/clojure "1.11.1"]
;; tools.namespace
[org.clojure/tools.namespace "1.3.0"]
;; java.data
[org.clojure/java.data "1.0.95"]
;; Logging
[com.taoensso/timbre "6.1.0"]
[com.fzakaria/slf4j-timbre "0.3.21"]
;; Profiling
[com.taoensso/tufte "2.4.5"]
;; Lifecycle management
[integrant "0.8.0"]
[integrant/repl "0.3.2"]
;; Command line parsing
[org.clojure/tools.cli "1.0.214"]
;; SCI
[org.babashka/sci "0.7.39"]
;; nREPL
[babashka/babashka.nrepl "0.0.7"]
[org.nrepl/incomplete "0.1.0"]
;; OpenJFX
[org.openjfx/javafx-controls "20"]
[org.openjfx/javafx-base "20"]
[org.openjfx/javafx-graphics "20"]
[org.openjfx/javafx-media "20"]
[org.openjfx/javafx-web "20"]]
:jvm-opts ["--enable-preview"]
:main ^:skip-aot poalses.jonathan.dialect.main
:target-path "target/%s"
:plugins [[lein-localrepo "0.5.4"]
[lein-cloverage "1.2.4"]
[lein-codox "0.10.8"]]
:codox {:metadata {:doc/format :markdown}
:project {:name "Dialect Detector"
:description "A handcrafted dialect detector for CS major project."}}
:cloverage {:ns-exclude-regex [#".*-debug" #".*main"]}
:profiles {:uberjar {:aot :all
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}
:dev {:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]}
:test {:plugins [[lein-test-report-junit-xml "0.2.0"]]
:dependencies [[com.github.seancorfield/expectations "2.0.165"]]}
:deploy {:plugins []}}
:repl-options {:init-ns user
:init (do (set! *print-length* 50)
(set! *print-level* 20))})
(ns poalses.jonathan.dialect.main
"Dialect detector entrypoint"
{:author "Jonathan Poalses"}
(:require [clojure.string :as string]
[clojure.tools.cli :as cli]
[taoensso.timbre :as log])
(:gen-class))
(def ^:private log-levels
"Supported log levels"
#{:trace :debug :info :warn :error :fatal})
(def command-line-options
"Command line options parsing rules."
[["-l" "--log-level LEVEL" (str "Logging level " (seq log-levels))
:default :info
:parse-fn #(keyword (string/join (rest %)))
:validate [#(contains? log-levels %)
(str "Must be one of: " (seq log-levels))]]
["-d" "--development" "Development mode"
:default false]
["-h" "--help" "Displays usage"
:default false]])
(defn- print-usage [options-summary]
(println (->> ["Dialect Detector"
""
"Usage: dialect-detector [options]"
""
"Options:"
options-summary
""
"Please refer to the manual page for more information."]
(string/join \newline))))
(defn process-args
"Processes command line `args`.
If help was requested, prints a usage message and exits.
If any problems were encountered parsing the command line, prints the errors and exits.
Returns map of parsed options:
| Key | Value
|--------------|------
| :development | Boolean development mode flag
| :log-level | Desired logging level, one of (:trace :debug :info :warn :error :fatal)
"
[args]
(let [{:keys [options errors summary]} (cli/parse-opts args command-line-options)]
(cond
(:help options)
(do
(print-usage summary)
(System/exit 0))
errors
(do
(println "Dialect Detector\n" (string/join \newline errors))
(System/exit -1))
:else options)))
(defn -main
"Dialect Detector entrypoint."
[& args]
(let [options (process-args args)]
(require '[taoensso.timbre :as log])
(log/set-min-level! (:log-level options))
(log/debug "Starting Dialect Detector...")
(try
(let [shutdown-trigger (promise)
_bye-testing-hack (future (Thread/sleep 6000) (deliver shutdown-trigger true))]
(log/info "Dialect Detector started up.")
@shutdown-trigger
(log/info "Dialect Detector shutting down..."))
(catch Exception e
(log/fatal "Dialect Detector encountered a problem." e)
(System/exit -666)))
(log/info "Dialect Detector shut down.")
(shutdown-agents)
(System/exit 0)))
;;==============================================================================
;;TINKERING
;;==============================================================================
(comment
*e)
;
; HissyBots REPL Service.
;
; Copyright (c) 2023, Hissycode Ltd. All rights reserved.
;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment