use default password lenght + minor fixes

This commit is contained in:
thez3ro 2018-01-21 02:32:46 +01:00
parent 27f8aa095a
commit e9612ee9e6
No known key found for this signature in database
GPG Key ID: F628F9E41DD7C073
3 changed files with 14 additions and 7 deletions

View File

@ -43,7 +43,7 @@ int Diceware::execute(QStringList arguments)
QCommandLineParser parser;
parser.setApplicationDescription(this->description);
QCommandLineOption wordlistFile(QStringList() << "w"
<< "wordlist",
<< "word-list",
QObject::tr("Wordlist fot the diceware generator.\n[Default: EFF English]"),
QObject::tr("path"));
parser.addOption(wordlistFile);
@ -68,7 +68,7 @@ int Diceware::execute(QStringList arguments)
}
if (!dicewareGenerator.isValid()) {
outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli passgen");
outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli diceware");
return EXIT_FAILURE;
}

View File

@ -42,6 +42,10 @@ int PassGen::execute(QStringList arguments)
QCommandLineParser parser;
parser.setApplicationDescription(this->description);
QCommandLineOption len(QStringList() << "L" << "length",
QObject::tr("Length of the generated password."),
QObject::tr("length"));
parser.addOption(len);
QCommandLineOption lower(QStringList() << "l",
QObject::tr("Use lowercase in the generated password."));
parser.addOption(lower);
@ -57,19 +61,22 @@ int PassGen::execute(QStringList arguments)
QCommandLineOption extended(QStringList() << "e",
QObject::tr("Use extended ascii in the generated password."));
parser.addOption(extended);
parser.addPositionalArgument("length", QObject::tr("Length of the generated password."));
parser.process(arguments);
const QStringList args = parser.positionalArguments();
if (args.size() != 1) {
if (args.size() != 0) {
outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli passgen");
return EXIT_FAILURE;
}
PasswordGenerator passwordGenerator;
int length = args.at(0).toInt();
passwordGenerator.setLength(length);
if (parser.value(len).isEmpty()) {
passwordGenerator.setLength(PasswordGenerator::DefaultLength);
} else {
int length = parser.value(len).toInt();
passwordGenerator.setLength(length);
}
PasswordGenerator::CharClasses classes = 0x0;

View File

@ -112,7 +112,7 @@ specified, a summary of the default attributes is given.
.SS "Diceware options"
.IP "-w, --wordlist <path>"
.IP "-w, --word-list <path>"
Path of the wordlist for the diceware generator. The wordlist must have > 1000 words,
otherwise the program will fail. If the wordlist has < 4000 words a warning will
be printed to STDERR.