Add the action-type to distinguish the actions.

This commit is contained in:
2023-09-16 22:05:53 +03:00
parent 5ca5765e01
commit 6d282e5ad4
2 changed files with 12 additions and 8 deletions
+10 -6
View File
@@ -62,7 +62,12 @@
(contains? options :message-file))
(or (contains? options :encrypt)
(contains? options :decrypt)))
{:options options :arguments arguments}
(cond
(contains? options :encrypt)
{:options options :arguments arguments :action-type :encrypt}
(contains? options :decrypt)
{:options options :arguments arguments :action-type :decrypt})
:else
{:exit-message (usage summary)})))
@@ -83,16 +88,15 @@
(file/read-file (:message-file options))))
(defn actions
[options arguments]
(println (str options arguments))
[options arguments action-type]
(let [message (get-message options arguments)
key (Integer/parseInt (:key options))
symbols "abc"]
symbols (:symbols options)]
(println
(cond
(contains? options :encrypt)
(= action-type :encrypt)
(caesar/encrypt-message message key symbols)
(contains? options :decrypt)
(= action-type :decrypt)
(caesar/decrypt-message message key symbols)))))