aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/decrypt_block.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-06-20 18:22:00 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-06-22 01:38:49 +0300
commit06b2428c2afaa36997a9d341bd497d42aa0fef89 (patch)
treeff83476738222578a19b59419fdbaa79a05156d7 /utils/decrypt_block.cpp
parentREADME update (diff)
downloadaes-tools-06b2428c2afaa36997a9d341bd497d42aa0fef89.tar.gz
aes-tools-06b2428c2afaa36997a9d341bd497d42aa0fef89.zip
utils: refactor command-line arguments parsing
+ update usage messages.
Diffstat (limited to '')
-rw-r--r--utils/decrypt_block.cpp65
1 files changed, 32 insertions, 33 deletions
diff --git a/utils/decrypt_block.cpp b/utils/decrypt_block.cpp
index 34f8abe..1337d55 100644
--- a/utils/decrypt_block.cpp
+++ b/utils/decrypt_block.cpp
@@ -164,49 +164,48 @@ int main(int argc, char** argv)
{
try
{
- CommandLineParser cmd_parser{argv[0]};
+ BlockSettings settings{argv[0]};
+
try
{
- std::vector<Input> inputs;
- const auto settings = cmd_parser.parse(argc, argv, inputs);
-
- if (cmd_parser.exit_with_usage())
- {
- std::cout << cmd_parser;
- return 0;
- }
-
- for (const auto& input : inputs)
- {
- if (settings.use_boxes)
- {
- decrypt_using_boxes(
- settings.algorithm,
- settings.mode,
- input);
- }
- else
- {
- decrypt_using_cxx_api(
- settings.algorithm,
- settings.mode,
- input,
- settings.verbose);
- }
- }
+ settings.parse(argc, argv);
}
catch (const boost::program_options::error& e)
{
- std::cerr << "Usage error: " << e.what() << "\n";
- std::cerr << cmd_parser;
+ settings.usage_error(e);
return 1;
}
- catch (const aes::Error& e)
+
+ if (settings.exit_with_usage)
{
- std::cerr << e;
- return 1;
+ settings.usage();
+ return 0;
+ }
+
+ for (const auto& input : settings.inputs)
+ {
+ if (settings.use_boxes)
+ {
+ decrypt_using_boxes(
+ settings.algorithm,
+ settings.mode,
+ input);
+ }
+ else
+ {
+ decrypt_using_cxx_api(
+ settings.algorithm,
+ settings.mode,
+ input,
+ settings.verbose);
+ }
}
}
+ catch (const aes::Error& e)
+ {
+ std::cerr << e;
+ return 1;
+ }
catch (const std::exception& e)
{
std::cerr << e.what() << "\n";