Improved --help and added --version

I added a --version longoption that says some stuff about the version and the copyright and the people who made mkp224o,

Also,

I made changes to the helpfile:
~ It now fits in small terminals that are 80 chars wide without being screen wrapped
~ It looks pretty like GNU utilities now
~ It has a couple less typos
~ It now has a link to the mkp224o homepage and a link to the issues page
~ And it now mentions the --help and --usage longoptions (and also the new --version longoption that I added)
This commit is contained in:
N1xis10t 2021-08-02 13:01:25 -06:00 committed by GitHub
parent fc6285523f
commit ec73643820
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

93
main.c
View file

@ -83,40 +83,70 @@ VEC_STRUCT(tstatsvec,struct tstatstruct);
static void printhelp(FILE *out,const char *progname)
{
fprintf(out,
"Usage: %s filter [filter...] [options]\n"
" %s -f filterfile [options]\n"
"Options:\n"
"\t-h - print help to stdout and quit\n"
"\t-f - specify filter file which contains filters separated by newlines\n"
"\t-D - deduplicate filters\n"
"\t-q - do not print diagnostic output to stderr\n"
"\t-x - do not print onion names\n"
"\t-v - print more diagnostic data\n"
"\t-o filename - output onion names to specified file (append)\n"
"\t-O filename - output onion names to specified file (overwrite)\n"
"\t-F - include directory names in onion names output\n"
"\t-d dirname - output directory\n"
"\t-t numthreads - specify number of threads to utilise (default - CPU core count or 1)\n"
"\t-j numthreads - same as -t\n"
"\t-n numkeys - specify number of keys (default - 0 - unlimited)\n"
"\t-N numwords - specify number of words per key (default - 1)\n"
"\t-Z - use \"slower\" key generation method (initial default)\n"
"\t-z - use \"faster\" key generation method (later default)\n"
"\t-B - use batching key generation method (>10x faster than -z, current default)\n"
"\t-s - print statistics each 10 seconds\n"
"\t-S t - print statistics every specified ammount of seconds\n"
"\t-T - do not reset statistics counters when printing\n"
"\t-y - output generated keys in YAML format instead of dumping them to filesystem\n"
"\t-Y [filename [host.onion]] - parse YAML encoded input and extract key(s) to filesystem\n"
"\t--rawyaml - raw (unprefixed) public/secret keys for -y/-Y (may be useful for tor controller API)\n"
"Usage: %s FILTER [FILTER...] [OPTION]\n"
" %s -f FILTERFILE [OPTION]\n"
"\n"
" -f, =FILTERFILE specify filter file which contains filters separated\n"
" by newlines\n"
" -D, deduplicate filters\n"
" -q, do not print diagnostic output to stderr\n"
" -x, do not print onion names\n"
" -v, print more diagnostic data\n"
" -o, =FILENAME output onion names to specified file (append)\n"
" -O, =FILENAME output onion names to specified file (overwrite)\n"
" -F, include directory names in onion names output\n"
" -d, =DIRNAME output directory\n"
" -t, =NUMTHREADS specify number of threads to utilise (default - CPU\n"
" core count or 1)\n"
" -j, =NUMTHREADS same as -t\n"
" -n, =NUMKEYS specify number of keys (default - 0 - unlimited)\n"
" -N, =NUMWORDS specify number of words per key (default - 1)\n"
" -Z, use \"slower\" key generation method (initial default)\n"
" -z, use \"faster\" key generation method (later default)\n"
" -B, use batching key generation method (>10x faster than\n"
" -z, current default)\n"
" -s, print statistics each 10 seconds\n"
" -S, =SECONDS print statistics every specified amount of seconds\n"
" -T, do not reset statistics counters when printing\n"
" -y, output generated keys in YAML format instead of\n"
" dumping them to filesystem\n"
" -Y, =[FILENAME [host.onion]]\n"
" parse YAML encoded input and extract key(s) to\n"
" filesystem\n"
#ifdef PASSPHRASE
"\t-p passphrase - use passphrase to initialize the random seed with\n"
"\t-P - same as -p, but takes passphrase from PASSPHRASE environment variable\n"
" -p, =PASSPHRASE use passphrase to initialize the random seed with\n"
" -P, same as -p, but takes passphrase from PASSPHRASE\n"
" environment variable\n"
#endif
" --rawyaml raw (unprefixed) public/secret keys for -y/-Y\n"
" (may be useful for tor controller API)\n"
" -h, --help print help to stdout and quit\n"
" --usage same as --help\n"
" --version print version information to stdout and exit\n"
"\n"
"Report bugs at: <https://github.com/cathugger/mkp224o/issues>\n"
"mkp224o home page: <https://github.com/cathugger/mkp224o>\n"
,progname,progname);
fflush(out);
}
static void printversion(FILE *out)
{
fprintf(out,
"mkp224o 1.5.0\n"
"Copyright (C) 2021 cathugger\n"
"License public domain:\n"
" CC0 1.0 <https://creativecommons.org/publicdomain/zero/1.0/>\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n"
"\n"
"mkp224o was mostly written by cathugger, but some other people helped too.\n"
"Please visit the mkp224o home page to find additional acknowledgements:\n"
"<https://github.com/cathugger/mkp224o>\n"
);
fflush(out);
}
static void e_additional(void)
{
fprintf(stderr,"additional argument required\n");
@ -246,8 +276,13 @@ int main(int argc,char **argv)
printhelp(stdout,progname);
exit(0);
}
else if (!strcmp(arg,"rawyaml"))
else if (!strcmp(arg,"rawyaml")) {
yamlraw = 1;
}
else if (!strcmp(arg,"version")) {
printversion(stdout);
exit(0);
}
else {
fprintf(stderr,"unrecognised argument: --%s\n",arg);
exit(1);