From 79a498022e83a89f4bb93e6e853bcd851f3b9a5c Mon Sep 17 00:00:00 2001 From: KKlochko Date: Thu, 28 Sep 2023 21:00:17 +0300 Subject: [PATCH] Add the file errors to prevent using an invalid file path. --- src/cipher_analytical_machine/cli.clj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cipher_analytical_machine/cli.clj b/src/cipher_analytical_machine/cli.clj index a201c9e..86c05eb 100644 --- a/src/cipher_analytical_machine/cli.clj +++ b/src/cipher_analytical_machine/cli.clj @@ -69,6 +69,12 @@ (map-has-keys? options [:message, :message-file]) {:exit-message (error-msg ["You can't use message and message-file options at the same time!!!"])} + (file/is-file-not-exists? (:message-file options)) + {:exit-message (error-msg ["Please, check the path to the message file!!!"])} + + (file/is-file-exists? (:output-file options)) + {:exit-message (error-msg ["Please, choose another file!!! Overwriting was prevented!!!"])} + (and (map-has-keys? options [:cipher, :key]) (or (contains? options :message) (contains? options :message-file))