Added option to specify set of symbols
This commit is contained in:
parent
10f1f6fee9
commit
2f06858506
@ -22,6 +22,7 @@ void print_help() {
|
|||||||
std::cout << " -l, --lower allow lower case letters\n";
|
std::cout << " -l, --lower allow lower case letters\n";
|
||||||
std::cout << " -u, --upper allow upper case letters\n";
|
std::cout << " -u, --upper allow upper case letters\n";
|
||||||
std::cout << " -s, --symbol allow symbols and punctuation\n";
|
std::cout << " -s, --symbol allow symbols and punctuation\n";
|
||||||
|
std::cout << " -S, --special allow symbols from specified argument\n";
|
||||||
std::cout << "When none of -d, -l, -u, and -s are given, pw acts as if all had been specified.\n";
|
std::cout << "When none of -d, -l, -u, and -s are given, pw acts as if all had been specified.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,10 +47,11 @@ int main(int argc, char* argv[]) {
|
|||||||
{"lower", no_argument, nullptr, 'l'},
|
{"lower", no_argument, nullptr, 'l'},
|
||||||
{"digit", no_argument, nullptr, 'd'},
|
{"digit", no_argument, nullptr, 'd'},
|
||||||
{"symbol", no_argument, nullptr, 's'},
|
{"symbol", no_argument, nullptr, 's'},
|
||||||
|
{"special", required_argument, nullptr, 'S'},
|
||||||
{"count", required_argument, nullptr, 'c'},
|
{"count", required_argument, nullptr, 'c'},
|
||||||
{nullptr, 0, nullptr, 0}
|
{nullptr, 0, nullptr, 0}
|
||||||
};
|
};
|
||||||
while ((opt_char = getopt_long(argc, argv, "c:hulds", long_options, nullptr)) != -1) {
|
while ((opt_char = getopt_long(argc, argv, "c:huldsS:", long_options, nullptr)) != -1) {
|
||||||
std::string arg {optarg ? optarg : ""};
|
std::string arg {optarg ? optarg : ""};
|
||||||
switch (opt_char) {
|
switch (opt_char) {
|
||||||
case 0: {
|
case 0: {
|
||||||
@ -80,6 +82,10 @@ int main(int argc, char* argv[]) {
|
|||||||
noflags = false;
|
noflags = false;
|
||||||
valid += symbols;
|
valid += symbols;
|
||||||
break;
|
break;
|
||||||
|
case 'S':
|
||||||
|
noflags = false;
|
||||||
|
valid += arg;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
len = std::stoi(optarg);
|
len = std::stoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user