mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 07:19:42 -05:00
Migrate entropy-meter to keepassxc-cli
This commit is contained in:
parent
9b92e7f8e8
commit
992d8a90c7
@ -254,7 +254,6 @@ include(FeatureSummary)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(share)
|
||||
add_subdirectory(utils)
|
||||
if(WITH_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif(WITH_TESTS)
|
||||
|
@ -16,6 +16,8 @@
|
||||
set(cli_SOURCES
|
||||
Merge.cpp
|
||||
Merge.h
|
||||
EntropyMeter.cpp
|
||||
EntropyMeter.h
|
||||
Extract.cpp
|
||||
Extract.h)
|
||||
|
||||
|
@ -6,6 +6,8 @@ Copyright (c) 2016, KeePassXC Team
|
||||
See zxcvbn/zxcvbn.cpp for complete COPYRIGHT Notice
|
||||
*/
|
||||
|
||||
#include "EntropyMeter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@ -76,7 +78,7 @@ static void calculate(const char *pwd, int advanced)
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int EntropyMeter::execute(int argc, char **argv)
|
||||
{
|
||||
printf("KeePassXC Entropy Meter, based on zxcvbn-c.\nEnter your password below or pass it as argv\n");
|
||||
printf(" Usage: entropy-meter [-a] [pwd1 pwd2 ...]\n> ");
|
27
src/cli/EntropyMeter.h
Normal file
27
src/cli/EntropyMeter.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSXC_ENTROPYMETER_H
|
||||
#define KEEPASSXC_ENTROPYMETER_H
|
||||
|
||||
class EntropyMeter
|
||||
{
|
||||
public:
|
||||
static int execute(int argc, char** argv);
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_ENTROPYMETER_H
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <cli/Merge.h>
|
||||
#include <cli/Extract.h>
|
||||
#include <cli/EntropyMeter.h>
|
||||
#include "config-keepassx.h"
|
||||
#include "core/Tools.h"
|
||||
#include "crypto/Crypto.h"
|
||||
@ -47,15 +48,17 @@ int main(int argc, char **argv)
|
||||
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
parser.process(app);
|
||||
// TODO : use process once the setOptionsAfterPositionalArgumentsMode (Qt 5.6)
|
||||
// is available. Until then, options passed to sub-commands won't be
|
||||
// recognized by this parser.
|
||||
// parser.process(app);
|
||||
|
||||
const QStringList args = parser.positionalArguments();
|
||||
if (args.size() < 1) {
|
||||
if (argc < 2) {
|
||||
parser.showHelp();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
QString commandName = args.at(0);
|
||||
QString commandName = argv[1];
|
||||
|
||||
for (int i = 1; i < argc - 1; ++i) {
|
||||
argv[i] = argv[i + 1];
|
||||
@ -73,6 +76,11 @@ int main(int argc, char **argv)
|
||||
return Extract::execute(argc, argv);
|
||||
}
|
||||
|
||||
if (commandName == "entropy-meter") {
|
||||
argv[0] = const_cast<char*>("keepassxc-cli entropy-meter");
|
||||
return EntropyMeter::execute(argc, argv);
|
||||
}
|
||||
|
||||
qCritical("Invalid command %s.", qPrintable(commandName));
|
||||
parser.showHelp();
|
||||
return EXIT_FAILURE;
|
||||
|
Loading…
Reference in New Issue
Block a user