Add -i/--include option to "generate" CLI command. (#7112)
This commit is contained in:
@@ -53,6 +53,12 @@ const QCommandLineOption Generate::ExcludeCharsOption = QCommandLineOption(QStri
|
||||
QObject::tr("Exclude character set"),
|
||||
QObject::tr("chars"));
|
||||
|
||||
const QCommandLineOption Generate::CustomCharacterSetOption =
|
||||
QCommandLineOption(QStringList() << "c"
|
||||
<< "custom",
|
||||
QObject::tr("Use custom character set"),
|
||||
QObject::tr("chars"));
|
||||
|
||||
const QCommandLineOption Generate::ExcludeSimilarCharsOption =
|
||||
QCommandLineOption(QStringList() << "exclude-similar", QObject::tr("Exclude similar looking characters"));
|
||||
|
||||
@@ -71,6 +77,7 @@ Generate::Generate()
|
||||
options.append(Generate::ExcludeCharsOption);
|
||||
options.append(Generate::ExcludeSimilarCharsOption);
|
||||
options.append(Generate::IncludeEveryGroupOption);
|
||||
options.append(Generate::CustomCharacterSetOption);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,9 +127,15 @@ QSharedPointer<PasswordGenerator> Generate::createGenerator(QSharedPointer<QComm
|
||||
|
||||
// The default charset will be used if no explicit class
|
||||
// option was set.
|
||||
passwordGenerator->setCharClasses(classes);
|
||||
passwordGenerator->setFlags(flags);
|
||||
passwordGenerator->setExcludedChars(parser->value(Generate::ExcludeCharsOption));
|
||||
if (flags != 0x0) {
|
||||
passwordGenerator->setFlags(flags);
|
||||
}
|
||||
QString customCharacterSet = parser->value(Generate::CustomCharacterSetOption);
|
||||
if (classes != 0x0 || !customCharacterSet.isNull()) {
|
||||
passwordGenerator->setCharClasses(classes);
|
||||
}
|
||||
passwordGenerator->setCustomCharacterSet(customCharacterSet);
|
||||
passwordGenerator->setExcludedCharacterSet(parser->value(Generate::ExcludeCharsOption));
|
||||
|
||||
if (!passwordGenerator->isValid()) {
|
||||
err << QObject::tr("Invalid password generator after applying all options") << endl;
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
static const QCommandLineOption ExcludeCharsOption;
|
||||
static const QCommandLineOption ExcludeSimilarCharsOption;
|
||||
static const QCommandLineOption IncludeEveryGroupOption;
|
||||
static const QCommandLineOption CustomCharacterSetOption;
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_GENERATE_H
|
||||
|
||||
Reference in New Issue
Block a user