From ef87a719a3485d16c88b60ee989e1591b80fa81c Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sat, 14 Oct 2023 17:28:21 +0300 Subject: [PATCH] Add validations to check if a cipher or an analyzer is available. --- src/cipher_analytical_machine/cli/cli.clj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cipher_analytical_machine/cli/cli.clj b/src/cipher_analytical_machine/cli/cli.clj index ddc269b..c92d888 100644 --- a/src/cipher_analytical_machine/cli/cli.clj +++ b/src/cipher_analytical_machine/cli/cli.clj @@ -62,6 +62,16 @@ (file/is-file-exists? (:output-file options))) {:exit-message (error-msg ["Please, choose another file!!! Overwriting was prevented!!!"])} + (false? (contains? options/cipher-options (:cipher options))) + {:exit-message (error-msg ["Please, choose an available cipher!!!\n" + (options/get-available-cipher-options-as-string)])} + + (and (map-has-keys? options [:cipher, :cracking, :analyzer]) + (false? (contains? + (get options/analyzers-options (:cipher options)) (:analyzer options)))) + {:exit-message (error-msg ["Please, choose an available analyzer!!!\n" + (options/get-available-analyzers-options-as-string)])} + (and (map-has-keys? options [:cipher, :key]) (or (contains? options :message) (contains? options :message-file))