diff --git a/src/tools/mdbx_chk.c b/src/tools/mdbx_chk.c index 745468a4..dfabd470 100644 --- a/src/tools/mdbx_chk.c +++ b/src/tools/mdbx_chk.c @@ -759,8 +759,8 @@ bailout: static void usage(char *prog) { fprintf(stderr, - "usage: %s dbpath [-V] [-v] [-n] [-q] [-w] [-c] [-d] [-s subdb]\n" - " -V\t\tshow version\n" + "usage: %s [-V] [-v] [-n] [-q] [-w] [-c] [-d] [-s subdb] dbpath\n" + " -V\t\tprint version and exit\n" " -v\t\tmore verbose, could be used multiple times\n" " -n\t\tNOSUBDIR mode for open\n" " -q\t\tbe quiet\n" diff --git a/src/tools/mdbx_copy.c b/src/tools/mdbx_copy.c index a58fd740..b3d0ea58 100644 --- a/src/tools/mdbx_copy.c +++ b/src/tools/mdbx_copy.c @@ -43,6 +43,19 @@ static void signal_handler(int sig) { #endif /* !WINDOWS */ +static void usage(const char *prog) { + fprintf(stderr, + "usage: %s [-V] [-q] [-c] [-n] src_path [dest_path]\n" + " -V\t\tprint version and exit\n" + " -q\t\tbe quiet\n" + " -c\t\tenable compactification (skip unused pages)\n" + " -n\t\tNOSUBDIR mode for open\n" + " src_path\tsource database\n" + " dest_path\tdestination (stdout if not specified)\n", + prog); + exit(EXIT_FAILURE); +} + int main(int argc, char *argv[]) { int rc; MDBX_env *env = NULL; @@ -58,6 +71,9 @@ int main(int argc, char *argv[]) { cpflags |= MDBX_CP_COMPACT; else if (argv[1][1] == 'q' && argv[1][2] == '\0') quiet = true; + else if ((argv[1][1] == 'h' && argv[1][2] == '\0') || + strcmp(argv[1], "--help") == 0) + usage(progname); else if (argv[1][1] == 'V' && argv[1][2] == '\0') { printf("mdbx_copy version %d.%d.%d.%d\n" " - source: %s %s, commit %s, tree %s\n" @@ -76,11 +92,8 @@ int main(int argc, char *argv[]) { argc = 0; } - if (argc < 2 || argc > 3) { - fprintf(stderr, "usage: %s [-V] [-q] [-c] [-n] srcpath [dstpath]\n", - progname); - exit(EXIT_FAILURE); - } + if (argc < 2 || argc > 3) + usage(progname); #if defined(_WIN32) || defined(_WIN64) SetConsoleCtrlHandler(ConsoleBreakHandlerRoutine, true); diff --git a/src/tools/mdbx_dump.c b/src/tools/mdbx_dump.c index adeaae4c..79dcce59 100644 --- a/src/tools/mdbx_dump.c +++ b/src/tools/mdbx_dump.c @@ -160,7 +160,18 @@ static int dumpit(MDBX_txn *txn, MDBX_dbi dbi, char *name) { static void usage(char *prog) { fprintf(stderr, - "usage: %s [-V] [-f output] [-l] [-n] [-p] [-a|-s subdb] dbpath\n", + "usage: %s [-V] [-q] [-f output] [-l] [-p] [-a|-s subdb] [-r] [-n] " + "dbpath\n" + " -V\t\tprint version and exit\n" + " -q\t\tbe quiet\n" + " -f\t\twrite to file instead of stdout\n" + " -l\t\tlist subDBs and exit\n" + " -p\t\tuse printable characters\n" + " -a\t\tdump main DB and all subDBs,\n" + " \t\tby default dump only the main DB\n" + " -s\t\tdump only the named subDB\n" + " -r\t\trescure mode (ignore errors to dump corrupted DB)\n" + " -n\t\tNOSUBDIR mode for open\n", prog); exit(EXIT_FAILURE); } @@ -178,14 +189,6 @@ int main(int argc, char *argv[]) { if (argc < 2) usage(prog); - /* -a: dump main DB and all subDBs - * -s: dump only the named subDB - * -n: use NOSUBDIR flag on env_open - * -p: use printable characters - * -f: write to file instead of stdout - * -V: print version and exit - * (default) dump only the main DB - */ while ((i = getopt(argc, argv, "af:lnps:Vrq")) != EOF) { switch (i) { case 'V': diff --git a/src/tools/mdbx_load.c b/src/tools/mdbx_load.c index 4d60fb32..e75b7a6f 100644 --- a/src/tools/mdbx_load.c +++ b/src/tools/mdbx_load.c @@ -307,7 +307,17 @@ static int readline(MDBX_val *out, MDBX_val *buf) { static void usage(void) { fprintf(stderr, - "usage: %s [-V] [-a] [-f input] [-n] [-s name] [-N] [-T] dbpath\n", + "usage: %s [-V] [-q] [-a] [-f file] [-s name] [-N] [-T] [-r] [-n] " + "dbpath\n" + " -V\t\tprint version and exit\n" + " -q\t\tbe quiet\n" + " -a\t\tappend records in input order\n" + " -f file\tread from file instead of stdin\n" + " -s name\tload into named subDB\n" + " -N\t\tuse NOOVERWRITE on puts\n" + " -T\t\tread plaintext\n" + " -r\t\trescure mode (ignore errors to load corrupted DB dump)\n" + " -n\t\tNOSUBDIR mode for open\n", prog); exit(EXIT_FAILURE); } @@ -335,14 +345,6 @@ int main(int argc, char *argv[]) { if (argc < 2) usage(); - /* -a: append records in input order - * -f: load file instead of stdin - * -n: use NOSUBDIR flag on env_open - * -s: load into named subDB - * -N: use NOOVERWRITE on puts - * -T: read plaintext - * -V: print version and exit - */ while ((i = getopt(argc, argv, "af:ns:NTVrq")) != EOF) { switch (i) { case 'V': diff --git a/src/tools/mdbx_stat.c b/src/tools/mdbx_stat.c index 04c1fb93..1f0289c4 100644 --- a/src/tools/mdbx_stat.c +++ b/src/tools/mdbx_stat.c @@ -54,7 +54,15 @@ static void prstat(MDBX_stat *ms) { static void usage(char *prog) { fprintf(stderr, - "usage: %s [-V] [-n] [-e] [-r[r]] [-f[f[f]]] [-a|-s subdb] dbpath\n", + "usage: %s [-V] [-e] [-r[r]] [-f[f[f]]] [-a|-s name] [-n] dbpath\n" + " -V\t\tprint version and exit\n" + " -a\t\tprint stat of main DB and all subDBs\n" + " -s name\tprint stat of only the named subDB\n" + " -e\t\tshow whole DB info\n" + " -f\t\tshow GC info\n" + " -r\t\tshow readers\n" + " \t\t(default) print stat of only the main DB\n" + " -n\t\tNOSUBDIR mode for open\n", prog); exit(EXIT_FAILURE); } @@ -95,15 +103,6 @@ int main(int argc, char *argv[]) { if (argc < 2) usage(prog); - /* -a: print stat of main DB and all subDBs - * -s: print stat of only the named subDB - * -e: print env info - * -f: print freelist info - * -r: print reader info - * -n: use NOSUBDIR flag on env_open - * -V: print version and exit - * (default) print stat of only the main DB - */ while ((o = getopt(argc, argv, "Vaefnrs:")) != EOF) { switch (o) { case 'V':