Compare commits
2 Commits
6c017b3262
...
cec35fc16b
| Author | SHA1 | Date | |
|---|---|---|---|
| cec35fc16b | |||
| e5fb6e7231 |
11
native.sh
11
native.sh
@@ -4,11 +4,18 @@ NATIVE=~/.sdkman/candidates/java/21.0.2-graalce/bin/native-image
|
||||
BIN_FILE=totp
|
||||
|
||||
echo "Creating uberjar"
|
||||
clojure -T:build uber
|
||||
#clojure -T:build uber
|
||||
UBERJAR=$(realpath --relative-to=target target/clj-totp-*-standalone.jar)
|
||||
|
||||
echo "Creating native image"
|
||||
$NATIVE -jar target/$UBERJAR -o target/$BIN_FILE -H:+ReportExceptionStackTraces --features=clj_easy.graal_build_time.InitClojureClasses --report-unsupported-elements-at-runtime --verbose --no-fallback -H:ReflectionConfigurationFiles=./reflect_config.json
|
||||
$NATIVE -jar target/$UBERJAR -o target/$BIN_FILE\
|
||||
-H:+ReportExceptionStackTraces\
|
||||
-H:ReflectionConfigurationFiles=./reflect_config.json\
|
||||
--verbose --no-fallback\
|
||||
--features=clj_easy.graal_build_time.InitClojureClasses\
|
||||
--report-unsupported-elements-at-runtime\
|
||||
--initialize-at-build-time=org.fusesource.jansi.Ansi\
|
||||
--trace-class-initialization=org.fusesource.jansi.Ansi
|
||||
|
||||
echo "Executable created on target/$BIN_FILE"
|
||||
cp target/$BIN_FILE ~/bin
|
||||
|
||||
@@ -9,26 +9,27 @@
|
||||
(:import [java.util TimerTask Timer])
|
||||
(:gen-class))
|
||||
|
||||
(def DEFAULT_BAR_STYLE :coloured-ascii-boxes)
|
||||
|
||||
(defn print-timer
|
||||
([] (print-timer 1 30))
|
||||
([start] (print-timer start 30))
|
||||
([start period]
|
||||
(let [a (atom start)]
|
||||
(pd/animate! a :opts {:total period
|
||||
([] (print-timer 1 30 DEFAULT_BAR_STYLE))
|
||||
([bar-style] (print-timer 1 30 bar-style))
|
||||
([start period bar-style]
|
||||
(let [a (atom start)]
|
||||
(pd/animate! a :opts {:total period
|
||||
;:line 1
|
||||
:label "Next TOTP: "
|
||||
:label "Next TOTP: "
|
||||
;:redraw-rate 60 ;; updates per second
|
||||
:style (:coloured-ascii-boxes pd/styles)}
|
||||
:style (get pd/styles bar-style)}
|
||||
;(println)
|
||||
(run! (fn [_] (Thread/sleep 1000) (swap! a inc)) (range start (inc period)))
|
||||
(run! (fn [_] (Thread/sleep 1000) (swap! a inc)) (range start (inc period)))
|
||||
;(println)
|
||||
))))
|
||||
))))
|
||||
|
||||
|
||||
(defn- print-confinuous
|
||||
([secret] (print-confinuous secret "sha1" 6 30 true))
|
||||
([secret algorithm digits period bar]
|
||||
([secret] (print-confinuous secret "sha1" 6 30 true DEFAULT_BAR_STYLE))
|
||||
([secret algorithm digits period bar bar-style]
|
||||
(let [step-millis (* 1000 period)
|
||||
now (System/currentTimeMillis)
|
||||
delay (int (- step-millis (rem now step-millis)))
|
||||
@@ -39,9 +40,9 @@
|
||||
task (proxy [TimerTask] []
|
||||
(run [] (println) (fn-show secret)))
|
||||
task-bar (proxy [TimerTask] []
|
||||
(run [] (print-timer)))
|
||||
(run [] (print-timer bar-style)))
|
||||
task-init (proxy [TimerTask] []
|
||||
(run [] (print-timer (- period delay-sec) period)))]
|
||||
(run [] (print-timer (- period delay-sec) period bar-style)))]
|
||||
(println "\n <Generating continuosly, press enter to stop>\n")
|
||||
;; (println "Now:" now ", Delay:" delay ", Next execution: " (+ now delay))
|
||||
(println "Refresing in" delay-sec "seconds")
|
||||
@@ -56,10 +57,10 @@
|
||||
|
||||
|
||||
(defn cmd-generate
|
||||
[& {:keys [secret continuous algorithm digits period bar]}]
|
||||
[& {:keys [secret continuous algorithm digits period bar bar-style]}]
|
||||
;;(pp/pprint opts)
|
||||
(if continuous
|
||||
(print-confinuous secret algorithm digits period bar)
|
||||
(print-confinuous secret algorithm digits period bar bar-style)
|
||||
(println (get-otp secret algorithm digits period))))
|
||||
|
||||
|
||||
@@ -96,7 +97,7 @@
|
||||
|
||||
|
||||
(defn cmd-get-multi
|
||||
[& {:keys [continuous bar _arguments]}]
|
||||
[& {:keys [continuous bar bar-style _arguments]}]
|
||||
;(pp/pprint opts)
|
||||
(with-config
|
||||
(let [apps (filter some? #_{:clj-kondo/ignore [:unresolved-symbol]}
|
||||
@@ -109,9 +110,9 @@
|
||||
delay (int (- step-millis (rem now step-millis)))
|
||||
delay-sec (int (/ delay 1000))
|
||||
task-bar (proxy [TimerTask] []
|
||||
(run [] (print-timer)))
|
||||
(run [] (print-timer bar-style)))
|
||||
task-init (proxy [TimerTask] []
|
||||
(run [] (print-timer (- period delay-sec) period)))]
|
||||
(run [] (print-timer (- period delay-sec) period bar-style)))]
|
||||
(print-app-continuous period apps)
|
||||
(when bar
|
||||
(. (new Timer) (schedule task-init 0))
|
||||
@@ -232,7 +233,11 @@
|
||||
{:option "bar" :short "b"
|
||||
:as "Show progress bar"
|
||||
:type :with-flag
|
||||
:default true}]
|
||||
:default true}
|
||||
{:option "bar-style" :short "s"
|
||||
:as "Progress bar style"
|
||||
:type #{:ascii-basic :ascii-boxes :coloured-ascii-boxes :emoji-circles :emoji-boxes}
|
||||
:default :coloured-ascii-boxes}]
|
||||
:runs cmd-generate}
|
||||
;; Generate a TOTP for a configured app
|
||||
{:command "get" :short "g"
|
||||
@@ -252,7 +257,11 @@
|
||||
{:option "bar" :short "b"
|
||||
:as "Show progress bar"
|
||||
:type :with-flag
|
||||
:default true}]
|
||||
:default true}
|
||||
{:option "bar-style" :short "s"
|
||||
:as "Progress bar style"
|
||||
:type #{:ascii-basic :ascii-boxes :coloured-ascii-boxes :emoji-circles :emoji-boxes}
|
||||
:default :coloured-ascii-boxes}]
|
||||
:runs cmd-get-multi}
|
||||
;; Check and init your config file
|
||||
{:command "config" :short "c"
|
||||
|
||||
Reference in New Issue
Block a user