Skip to content

Commit

Permalink
Added REPL banner.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryugi committed May 27, 2017
1 parent 1760cfe commit 8cf1015
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 6 deletions.
9 changes: 8 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,11 @@
"timi-deploy" ["with-profile" "build" "deploy" "clojars"]
"timi-server-docs" ["with-profile" "+build,+docs,+server-docs" "codox"]
"timi-client-docs" ["with-profile" "+build,+docs,+client-docs" "codox"]
"timi-docs" ["do" ["timi-server-docs"] ["timi-client-docs"]]})
"timi-docs" ["do" ["timi-server-docs"] ["timi-client-docs"]]}
:repl-options {
:prompt (fn [ns] (str "\u001B[35m[\u001B[34m"
ns
"\u001B[35m]\u001B[33m λ:\u001B[m "))
:welcome ~(do
(println (slurp "resources/text/banner.txt"))
(println (slurp "resources/text/loading.txt")))})
11 changes: 11 additions & 0 deletions resources/text/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


______ __
/\__ _\ / / Tracking REPL
\/_/\ \//_/ ___ ___ _
\ \ \/\ \ /' __` __`\/\ \
\ \ \ \ \/\ \/\ \/\ \ \ \
\ \_\ \_\ \_\ \_\ \_\ \_\
\/_/\/_/\/_/\/_/\/_/\/_/


3 changes: 3 additions & 0 deletions resources/text/loading.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When the REPL finishes loading, type (start)

Loading Clojure code ...
8 changes: 6 additions & 2 deletions src/clj/timi/server/cli/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

(def options
[["-h" "--help"]
["-b" "--banner"]
["-v" "--version"]
["-s" "--summary"]
["-l" "--log-level LOG-LEVEL" "Log level for CLI"
Expand Down Expand Up @@ -53,6 +54,8 @@
data
(:summary options)
data
(:banner options)
data
(:unsupported parsed)
(format "\nERROR: %s\n\n%s" data (help))
(:completed parsed)
Expand Down Expand Up @@ -80,10 +83,11 @@
Options:
```
-b, --banner Show the Tímı banner
-h, --help Display this help text
-v, --version Current version of Tímı
-s, --summary Get the generated summary
-l, --log-level=LOG-LEVEL Set the server-side CLI log level
-s, --summary Get the generated summary
-v, --version Current version of Tímı
```
Commands:
```
Expand Down
2 changes: 2 additions & 0 deletions src/clj/timi/server/cli/parser.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
(assoc parsed :data (util/get-version))
(:help options)
parsed
(:banner options)
(assoc parsed :data (util/get-banner))
(:log-level options)
(let [log-level (:log-level options)]
(log/warn "Setting log level to " log-level)
Expand Down
8 changes: 6 additions & 2 deletions src/clj/timi/server/components/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[taoensso.timbre :as log]
[timi.server.components.cli :as cli]
[timi.server.components.config :as config]
[timi.server.components.db :as db]
[timi.server.components.httpd :as httpd]
[timi.server.components.logging :as logging]))

Expand All @@ -15,12 +16,15 @@
:logger (component/using
(logging/new-logger)
[:cfg-mgr])
:db (component/using
(db/new-db-manager)
[:cfg-mgr :logger])
:cli (component/using
(cli/new-server)
[:cfg-mgr :logger])
[:cfg-mgr :logger :db])
:httpd (component/using
(httpd/new-server app)
[:cfg-mgr :logger])))
[:cfg-mgr :logger :db])))

(defn stop [system component-key]
(->> system
Expand Down
5 changes: 4 additions & 1 deletion src/clj/timi/server/util.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns timi.server.util
(:require
[clojure.java.io :as io]
[clojusc.twig :as logger]))

(defn str->decimal
Expand Down Expand Up @@ -48,4 +49,6 @@
:cli-server (set-log-level-type config [:cli :server :log] level)
:repl (set-log-level-type config [:repl :log] level))))


(defn get-banner
[]
(slurp (io/resource "text/banner.txt")))

0 comments on commit 8cf1015

Please sign in to comment.