|
|
|
@ -28,6 +28,7 @@
|
|
|
|
|
["-l" "--language CODE" "The string will be used to set a default symbols for a cipher."
|
|
|
|
|
:validate [#(contains? language-options %) "Must be a code from the list: en, uk!!!"]]
|
|
|
|
|
["-C" "--cracking" "Cracking the encrypted message."]
|
|
|
|
|
["-O" "--output-file OUTPUT-FILE" "Save the program output to a file."]
|
|
|
|
|
["-h" "--help"]])
|
|
|
|
|
|
|
|
|
|
(defn usage [options-summary]
|
|
|
|
@ -129,6 +130,18 @@
|
|
|
|
|
(set-symbols)
|
|
|
|
|
(load-and-set-option :message)))
|
|
|
|
|
|
|
|
|
|
(defn save-output
|
|
|
|
|
"Save the output to a file"
|
|
|
|
|
[output options]
|
|
|
|
|
(let [file-path (:output-file options)]
|
|
|
|
|
(file/write-file file-path output)))
|
|
|
|
|
|
|
|
|
|
(defn show-and-save-output
|
|
|
|
|
"Print and save the output to a file if needed"
|
|
|
|
|
[output options]
|
|
|
|
|
(save-output output options)
|
|
|
|
|
(println output))
|
|
|
|
|
|
|
|
|
|
(defn cracking-actions
|
|
|
|
|
[options arguments action-type]
|
|
|
|
|
(let [message (:message options)
|
|
|
|
@ -154,11 +167,13 @@
|
|
|
|
|
(defn actions
|
|
|
|
|
[options arguments action-type]
|
|
|
|
|
(let [options (load-all-options options)]
|
|
|
|
|
(println
|
|
|
|
|
(->
|
|
|
|
|
(cond
|
|
|
|
|
(contains? #{:encrypt :decrypt} action-type)
|
|
|
|
|
(crypt-actions options arguments action-type)
|
|
|
|
|
|
|
|
|
|
(= action-type :cracking)
|
|
|
|
|
(cracking-actions options arguments action-type)))))
|
|
|
|
|
(cracking-actions options arguments action-type))
|
|
|
|
|
|
|
|
|
|
(show-and-save-output options))))
|
|
|
|
|
|
|
|
|
|