aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/encrypt_file.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-08-04 04:37:12 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-08-04 04:37:12 +0300
commit0c593583dccd88e90450972e6a1b9e6bc67e0911 (patch)
treed38de5fb6255fec9424bf9694c1cf3fcfd8b9c39 /utils/encrypt_file.cpp
parenttest/toolkit.py: fix utility names (diff)
downloadaes-tools-0c593583dccd88e90450972e6a1b9e6bc67e0911.tar.gz
aes-tools-0c593583dccd88e90450972e6a1b9e6bc67e0911.zip
utils: bugfix & refactoring
Diffstat (limited to 'utils/encrypt_file.cpp')
-rw-r--r--utils/encrypt_file.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/utils/encrypt_file.cpp b/utils/encrypt_file.cpp
index 5747536..0619568 100644
--- a/utils/encrypt_file.cpp
+++ b/utils/encrypt_file.cpp
@@ -6,7 +6,7 @@
* See LICENSE.txt for details.
*/
-#include "file_common.hpp"
+#include "file_cmd_parser.hpp"
#include <aesni/all.h>
@@ -20,8 +20,8 @@
#include <exception>
#include <fstream>
#include <iostream>
+#include <iterator>
#include <string>
-#include <utility>
#include <vector>
namespace
@@ -77,7 +77,7 @@ namespace
}
if (args.size() != 2)
- return true;
+ return false;
const auto src_path = args[0];
const auto dest_path = args[1];
@@ -165,13 +165,20 @@ int main(int argc, char** argv)
try
{
CommandLineParser cmd_parser("encrypt_file.exe");
+ cmd_parser.parse(argc, argv);
- if (!cmd_parser.parse_options(argc, argv))
+ if (cmd_parser.requested_help())
+ {
+ std::cout << cmd_parser;
return 0;
+ }
+
+ std::deque<std::string> args{ std::make_move_iterator(cmd_parser.args.begin()),
+ std::make_move_iterator(cmd_parser.args.end()) };
- if (!encrypt_file(cmd_parser.get_algorithm(), cmd_parser.get_mode(), cmd_parser.get_args()))
+ if (!encrypt_file(cmd_parser.algorithm, cmd_parser.mode, args))
{
- cmd_parser.print_usage();
+ std::cout << cmd_parser;
return 1;
}