Add the language option for symbols.
This commit is contained in:
@@ -12,6 +12,9 @@
|
|||||||
(def cipher-options
|
(def cipher-options
|
||||||
#{"Caesar"})
|
#{"Caesar"})
|
||||||
|
|
||||||
|
(def language-options
|
||||||
|
#{"en", "uk"})
|
||||||
|
|
||||||
(def cli-options
|
(def cli-options
|
||||||
[["-m" "--message MESSAGE" "The message will be encrypted or decrypted."]
|
[["-m" "--message MESSAGE" "The message will be encrypted or decrypted."]
|
||||||
["-M" "--message-file MESSAGE-FILE" "The file contains the message that will be encrypted or decrypted."]
|
["-M" "--message-file MESSAGE-FILE" "The file contains the message that will be encrypted or decrypted."]
|
||||||
@@ -22,6 +25,8 @@
|
|||||||
["-d" "--decrypt" "Decrypt the message."]
|
["-d" "--decrypt" "Decrypt the message."]
|
||||||
["-s" "--symbols" "The string will be used as a set of symbols for a cipher."
|
["-s" "--symbols" "The string will be used as a set of symbols for a cipher."
|
||||||
:default (sf/default-symbol-factory "en")]
|
:default (sf/default-symbol-factory "en")]
|
||||||
|
["-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."]
|
["-C" "--cracking" "Cracking the encrypted message."]
|
||||||
["-h" "--help"]])
|
["-h" "--help"]])
|
||||||
|
|
||||||
@@ -105,6 +110,12 @@
|
|||||||
(-> options
|
(-> options
|
||||||
(assoc option value)))
|
(assoc option value)))
|
||||||
|
|
||||||
|
(defn set-symbols
|
||||||
|
"Set defaults symbols for a language."
|
||||||
|
[options]
|
||||||
|
(set-option options :symbols
|
||||||
|
(sf/default-symbol-factory (:language options))))
|
||||||
|
|
||||||
(defn load-and-set-option
|
(defn load-and-set-option
|
||||||
"Load the option and set it."
|
"Load the option and set it."
|
||||||
[options option]
|
[options option]
|
||||||
@@ -115,6 +126,7 @@
|
|||||||
"Load all options."
|
"Load all options."
|
||||||
[options]
|
[options]
|
||||||
(-> options
|
(-> options
|
||||||
|
(set-symbols)
|
||||||
(load-and-set-option :message)))
|
(load-and-set-option :message)))
|
||||||
|
|
||||||
(defn cracking-actions
|
(defn cracking-actions
|
||||||
|
|||||||
Reference in New Issue
Block a user