diff --git a/doc/mdb-count.txt b/doc/mdb-count.txt index c586608..2350b97 100644 --- a/doc/mdb-count.txt +++ b/doc/mdb-count.txt @@ -3,6 +3,7 @@ NAME SYNOPSIS mdb-count file table + mdb-count --version DESCRIPTION mdb-count is a utility program distributed with MDB Tools. @@ -10,6 +11,7 @@ DESCRIPTION It outputs the number of rows in a table. OPTIONS + --version Print the mdbtools version and exit. NOTES diff --git a/doc/mdb-export.txt b/doc/mdb-export.txt index 5e726c5..8e866a2 100644 --- a/doc/mdb-export.txt +++ b/doc/mdb-export.txt @@ -5,6 +5,7 @@ SYNOPSIS mdb-export [--no-header] [--delimiter delim] [--row-delimiter delim] [[--no-quote] | [--quote char [--escape char]]] [--escape-invisible] [--date-format fmt] [--datetime-format fmt] [--bin strip|raw|octal|hex] [--boolean-words] database table mdb-export --insert backend [--namespace prefix] [--batch-size int] database table mdb-export -h|--help + mdb-export --version DESCRIPTION mdb-export is a utility program distributed with MDB Tools. @@ -29,6 +30,7 @@ OPTIONS -0, --null char Use char to represent a NULL value. -b, --bin strip|raw|octal|hex Binary export mode: strip binaries, export as-is, output \\ooo style octal data or output \\xx style hexadecimal data. -B, --boolean-words Use TRUE/FALSE in Boolean fields (default is 0/1). + --version Print the mdbtools version and exit. NOTES Most of the formatting options actually also works with --insert. diff --git a/doc/mdb-import.txt b/doc/mdb-import.txt index 89e6003..26a1f59 100644 --- a/doc/mdb-import.txt +++ b/doc/mdb-import.txt @@ -4,6 +4,7 @@ NAME SYNOPSIS mdb-import [-H lines] [-d char] database table csvfile mdb-import -h|--help + mdb-import --version DESCRIPTION mdb-import is a utility program distributed with MDB Tools. @@ -13,6 +14,7 @@ DESCRIPTION OPTIONS -H, --header lines Skip lines of CSV header. -d, --delimiter char Specify an alternative column delimiter. Default is , (comma). + --version Print the mdbtools version and exit NOTES diff --git a/doc/mdb-json.txt b/doc/mdb-json.txt index df9cac1..5b76766 100644 --- a/doc/mdb-json.txt +++ b/doc/mdb-json.txt @@ -4,6 +4,7 @@ NAME SYNOPSIS mdb-json [-D fmt] [-T fmt] [-U] database table mdb-json -h|--help + mdb-json --version DESCRIPTION mdb-json is a utility program distributed with MDB Tools. @@ -13,7 +14,8 @@ DESCRIPTION OPTIONS -D, --date-format fmt Set the date format (see strftime(3) for details). -T, --time-format fmt Set the date/time format (see strftime(3) for details). - -U, --no-unprintable Change unprintable characters to spaces (otherwise escaped as \\u00XX) + -U, --no-unprintable Change unprintable characters to spaces (otherwise escaped as \\u00XX). + --version Print the mdbtools version and exit. NOTES diff --git a/doc/mdb-prop.txt b/doc/mdb-prop.txt index 1f1f3ba..18b32fe 100644 --- a/doc/mdb-prop.txt +++ b/doc/mdb-prop.txt @@ -3,6 +3,7 @@ NAME SYNOPSIS mdb-prop database name [propcol] + mdb-prop --version DESCRIPTION mdb-prop is a utility program distributed with MDB Tools. @@ -13,6 +14,9 @@ DESCRIPTION propcol is the name of the system table MSysObjects' column containing properties. It defaults to LvProp. +OPTIONS + --version Print the mdbtools version and exit. + ENVIRONMENT MDB_JET3_CHARSET Defines the charset of the input JET3 (access 97) file. Default is CP1252. See iconv(1). MDBICONV Defines the output charset. Default is UTF-8. mdbtools must have been compiled with iconv. diff --git a/doc/mdb-queries.txt b/doc/mdb-queries.txt index d5620a9..2f02938 100644 --- a/doc/mdb-queries.txt +++ b/doc/mdb-queries.txt @@ -3,6 +3,7 @@ NAME SYNOPSIS mdb-queries [-L] [-1] [-d delim] database query + mdb-queries --version mdb-queries -h|--help DESCRIPTION @@ -13,7 +14,8 @@ DESCRIPTION OPTIONS -L, --list List queries in the database (default if no query name is passed) -1, --newline Use newline as the delimiter (used in conjunction with listing) - -d, --delimiter delim Specify delimiter to use + -d, --delimiter delim Specify delimiter to use (defaults to space) + --version Print the mdbtools version and exit NOTES diff --git a/doc/mdb-schema.txt b/doc/mdb-schema.txt index ac318b6..94473cc 100644 --- a/doc/mdb-schema.txt +++ b/doc/mdb-schema.txt @@ -4,6 +4,7 @@ NAME SYNOPSIS mdb-schema [options] [-T tablename] [-N prefix] database [backend] mdb-schema -h|--help + mdb-schema --version DESCRIPTION mdb-schema is a utility program distributed with MDB Tools. @@ -27,6 +28,7 @@ OPTIONS --no-indexes Don't export INDEXes. --relations Export foreign keys constraints. This is the default. --no-relations Don't export foreign keys constraints. + --version Print the mdbtools version and exit. backend Specifies target DDL dialect. Supported values are access, sybase, oracle, postgres, mysql and sqlite. If not specified the generated DDL will be in access format. diff --git a/doc/mdb-sql.txt b/doc/mdb-sql.txt index 2af4679..61cd54c 100644 --- a/doc/mdb-sql.txt +++ b/doc/mdb-sql.txt @@ -4,6 +4,7 @@ NAME SYNOPSIS mdb-sql [-HFp] [-d char] [-i file] [-o file] [database] mdb-sql -h|--help + mdb-sql --version DESCRIPTION mdb-sql is a utility program distributed with MDB Tools. @@ -23,6 +24,7 @@ specified, columns will be delimited by a tab character if pretty printing (-p) is turned off. If pretty printing is enabled this option is meaningless. -i, --input file Specify an input file. This option allows an input file containing the SQL to be passed to mdb-sql. See Notes. -o, --output file Specify an output file. This option allows the name of an output file to be used instead of stdout. + --version Print the mdbtools version and exit. COMMANDS mdb-sql in interactive mode takes some special commands. diff --git a/doc/mdb-tables.txt b/doc/mdb-tables.txt index 93fcaf7..2cf0e34 100644 --- a/doc/mdb-tables.txt +++ b/doc/mdb-tables.txt @@ -4,6 +4,7 @@ NAME SYNOPSIS mdb-tables [-S] [-1 | -d delim] [-t form|table|macro|systable|report|query|linkedtable|module|relationship|dbprop|any|all] [-T] database mdb-tables -h|--help + mdb-tables --version DESCRIPTION mdb-tables is a utility program distributed with MDB Tools. @@ -16,6 +17,7 @@ OPTIONS -d, --delimiter delim Specifies an alternative delimiter. If no delimiter is specified, table names will be delimited by a tab character, or by newline if the -1 option was specified. -t, --type type Filters entries to show alternate types. Autorized values are form, table, macro, systable, report, query, linkedtable, module, relationship, dbprop, any, and all. Default value is table. -T, --showtype Display the entry type indentifier before each entry. + --version Print the mdbtools version and exit. NOTES diff --git a/doc/mdb-ver.txt b/doc/mdb-ver.txt index 4e3888d..3c3c1fc 100644 --- a/doc/mdb-ver.txt +++ b/doc/mdb-ver.txt @@ -3,8 +3,8 @@ NAME SYNOPSIS mdb-ver database - mdb-ver -M mdb-ver -h|--help + mdb-ver -M|--version DESCRIPTION mdb-ver is a utility program distributed with MDB Tools. @@ -12,8 +12,7 @@ DESCRIPTION It will return a single line of output corresponding to the program that produced the file: 'JET3' (for files produced by Access 97), 'JET4' (Access 2000, XP and 2003), 'ACE12' (Access 2007), 'ACE14' (Access 2010), 'ACE15' (Access 2013), or 'ACE16' (Access 2016). OPTIONS - - -M, --mdbtools Prints the version of MDB Tools itself instead of the MDB file. + -M, --version Print the version of mdbtools (rather than the MDB file) and exit. NOTES Access changed its format between Jet 3 used in Access 97 and Jet 4 used for Access 2000 and XP. The nature of the changes included moving the page size from 2K to 4K and added support for unicode. MDB Tools actively supports both formats. Newer version are very much like Jet4. diff --git a/src/util/mdb-count.c b/src/util/mdb-count.c index 7ccc8c4..74e6815 100644 --- a/src/util/mdb-count.c +++ b/src/util/mdb-count.c @@ -17,6 +17,7 @@ */ #include "mdbtools.h" +#include "mdbver.h" int main(int argc, char **argv) { @@ -28,10 +29,39 @@ int main(int argc, char **argv) { char *locale = NULL; char *table_name = NULL; GError *error = NULL; + int print_mdbver = 0; - if (argc < 3) { - fprintf(stderr, "Usage: %s \n", argv[0]); - return 1; + GOptionContext *opt_context; + GOptionEntry entries[] = { + {"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL}, + {NULL} + }; + opt_context = g_option_context_new("
- print the number of records in an Access database"); + g_option_context_add_main_entries(opt_context, entries, NULL /*i18n*/); + locale = setlocale(LC_CTYPE, ""); + if (!g_option_context_parse (opt_context, &argc, &argv, &error)) + { + fprintf(stderr, "option parsing failed: %s\n", error->message); + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + return 1; + } + if (print_mdbver) { + if (argc > 1) { + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + } + fprintf(stdout,"%s\n", MDB_FULL_VERSION); + exit(argc > 1); + } + if (argc != 3) { + fputs("Wrong number of arguments.\n\n", stderr); + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + return 1; + } + table_name = g_locale_to_utf8(argv[2], -1, NULL, NULL, &error); + setlocale(LC_CTYPE, locale); + if (!table_name) { + fprintf(stderr, "Error converting table argument: %s\n", error->message); + return 1; } // open db and try to read table: @@ -42,13 +72,6 @@ int main(int argc, char **argv) { if (!mdb_read_catalog(mdb, MDB_TABLE)) { return 1; } - locale = setlocale(LC_CTYPE, ""); - table_name = g_locale_to_utf8(argv[2], -1, NULL, NULL, &error); - setlocale(LC_CTYPE, locale); - if (!table_name) { - fprintf(stderr, "Error converting table argument: %s\n", error->message); - return 1; - } for (i = 0; i < mdb->num_catalog; i++) { entry = g_ptr_array_index(mdb->catalog, i); if (entry->object_type == MDB_TABLE && !g_ascii_strcasecmp(entry->object_name, table_name)) { diff --git a/src/util/mdb-export.c b/src/util/mdb-export.c index 73f5a64..eaeff51 100755 --- a/src/util/mdb-export.c +++ b/src/util/mdb-export.c @@ -17,6 +17,7 @@ */ #include "mdbtools.h" +#include "mdbver.h" #define EXPORT_BIND_SIZE 200000 @@ -56,6 +57,7 @@ main(int argc, char **argv) int ret; char *locale = NULL; char *table_name = NULL; + int print_mdbver = 0; GOptionEntry entries[] = { {"no-header", 'H', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &header_row, "Suppress header row.", NULL}, @@ -73,6 +75,7 @@ main(int argc, char **argv) {"null", '0', 0, G_OPTION_ARG_STRING, &null_text, "Use to represent a NULL value", "char"}, {"bin", 'b', 0, G_OPTION_ARG_STRING, &str_bin_mode, "Binary export mode", "strip|raw|octal|hex"}, {"boolean-words", 'B', 0, G_OPTION_ARG_NONE, &boolean_words, "Use TRUE/FALSE in Boolean fields (default is 0/1)", NULL}, + {"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL}, {NULL}, }; GError *error = NULL; @@ -88,7 +91,13 @@ main(int argc, char **argv) fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); exit (1); } - + if (print_mdbver) { + if (argc > 1) { + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + } + fprintf(stdout,"%s\n", MDB_FULL_VERSION); + exit(argc > 1); + } if (argc != 3) { fputs("Wrong number of arguments.\n\n", stderr); fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); diff --git a/src/util/mdb-import.c b/src/util/mdb-import.c index 15993be..ad871e4 100644 --- a/src/util/mdb-import.c +++ b/src/util/mdb-import.c @@ -17,6 +17,7 @@ */ #include "mdbtools.h" +#include "mdbver.h" #define MAX_ROW_SIZE 4096 @@ -158,10 +159,12 @@ main(int argc, char **argv) FILE *in; char *delimiter; int header_rows = 0; + int print_mdbver = 0; GOptionEntry entries[] = { { "header", 'H', 0, G_OPTION_ARG_INT, &header_rows, "skip header rows", "row"}, { "delimiter", 'd', 0, G_OPTION_ARG_STRING, &delimiter, "Specify a column delimiter", "char"}, + {"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL}, { NULL }, }; GError *error = NULL; @@ -176,6 +179,13 @@ main(int argc, char **argv) fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); exit (1); } + if (print_mdbver) { + if (argc > 1) { + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + } + fprintf(stdout,"%s\n", MDB_FULL_VERSION); + exit(argc > 1); + } if (!delimiter) delimiter = g_strdup(","); diff --git a/src/util/mdb-json.c b/src/util/mdb-json.c index f9ba44d..67b3ac8 100644 --- a/src/util/mdb-json.c +++ b/src/util/mdb-json.c @@ -17,6 +17,7 @@ */ #include "mdbtools.h" +#include "mdbver.h" #include "base64.h" @@ -115,11 +116,13 @@ main(int argc, char **argv) int ret; char *table_name = NULL; char *locale = NULL; + int print_mdbver = 0; GOptionEntry entries[] = { {"date-format", 'D', 0, G_OPTION_ARG_STRING, &shortdate_fmt, "Set the date format (see strftime(3) for details)", "format"}, {"datetime-format", 'T', 0, G_OPTION_ARG_STRING, &date_fmt, "Set the date/time format (see strftime(3) for details)", "format"}, {"no-unprintable", 'U', 0, G_OPTION_ARG_NONE, &drop_nonascii, "Change unprintable characters to spaces (otherwise escaped as \\u00XX)", NULL}, + {"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL}, {NULL} }; @@ -135,6 +138,13 @@ main(int argc, char **argv) fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); exit (1); } + if (print_mdbver) { + if (argc > 1) { + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + } + fprintf(stdout,"%s\n", MDB_FULL_VERSION); + exit(argc > 1); + } if (argc != 3) { fputs("Wrong number of arguments.\n\n", stderr); fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); diff --git a/src/util/mdb-prop.c b/src/util/mdb-prop.c index a77d93e..a6871e8 100644 --- a/src/util/mdb-prop.c +++ b/src/util/mdb-prop.c @@ -17,6 +17,7 @@ */ #include "mdbtools.h" +#include "mdbver.h" void dump_kkd(MdbHandle *mdb, void *kkd, size_t len); @@ -32,10 +33,43 @@ main(int argc, char **argv) void *buf; int col_num; int found = 0; + int print_mdbver = 0; + GError *error = NULL; - if (argc < 3) { - fprintf(stderr,"Usage: %s []\n", - argv[0]); + GOptionContext *opt_context; + GOptionEntry entries[] = { + {"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL}, + {NULL} + }; + opt_context = g_option_context_new(" [] - display properties of an object in an Access database"); + g_option_context_add_main_entries(opt_context, entries, NULL /*i18n*/); + locale = setlocale(LC_CTYPE, ""); + if (!g_option_context_parse (opt_context, &argc, &argv, &error)) + { + fprintf(stderr, "option parsing failed: %s\n", error->message); + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + return 1; + } + if (print_mdbver) { + if (argc > 1) { + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + } + fprintf(stdout,"%s\n", MDB_FULL_VERSION); + exit(argc > 1); + } + if (argc != 3 && argc != 4) { + fputs("Wrong number of arguments.\n\n", stderr); + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + return 1; + } + + table_name = g_locale_to_utf8(argv[2], -1, NULL, NULL, NULL); + if (argc < 4) + propColName = g_strdup("LvProp"); + else + propColName = g_locale_to_utf8(argv[3], -1, NULL, NULL, NULL); + setlocale(LC_CTYPE, locale); + if (!table_name || !propColName) { return 1; } @@ -44,17 +78,6 @@ main(int argc, char **argv) return 1; } - locale = setlocale(LC_CTYPE, ""); - table_name = g_locale_to_utf8(argv[2], -1, NULL, NULL, NULL); - if (argc < 4) - propColName = g_strdup("LvProp"); - else - propColName = g_locale_to_utf8(argv[3], -1, NULL, NULL, NULL); - setlocale(LC_CTYPE, locale); - if (!table_name || !propColName) { - mdb_close(mdb); - return 1; - } table = mdb_read_table_by_name(mdb, "MSysObjects", MDB_ANY); if (!table) { g_free(table_name); diff --git a/src/util/mdb-queries.c b/src/util/mdb-queries.c index 0f67fd8..248a844 100644 --- a/src/util/mdb-queries.c +++ b/src/util/mdb-queries.c @@ -32,6 +32,7 @@ **************************************************************/ #include "mdbtools.h" +#include "mdbver.h" #define QUERY_BIND_SIZE 200000 @@ -68,6 +69,7 @@ int main (int argc, char **argv) { char *sql_sorting = malloc(bind_size); int flagint; char *locale = NULL; + int print_mdbver = 0; GError *error = NULL; GOptionContext *opt_context; @@ -76,6 +78,7 @@ int main (int argc, char **argv) { {"list", 'L', 0, G_OPTION_ARG_NONE, &list_only, "List queries in the database (default if no query name is passed)", NULL}, {"newline", '1', 0, G_OPTION_ARG_NONE, &line_break, "Use newline as the delimiter (used in conjunction with listing)", NULL}, {"delimiter", 'd', 0, G_OPTION_ARG_STRING, &delimiter, "Specify delimiter to use", "delim"}, + {"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL}, {NULL} }; opt_context = g_option_context_new(" - list or export queries from an Access database"); @@ -87,6 +90,13 @@ int main (int argc, char **argv) { fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); exit (1); } + if (print_mdbver) { + if (argc > 1) { + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + } + fprintf(stdout,"%s\n", MDB_FULL_VERSION); + exit(argc > 1); + } /* let's turn list_only on if only a database filename was passed */ if(argc == 2) { list_only=1; diff --git a/src/util/mdb-schema.c b/src/util/mdb-schema.c index 9adc02a..65d53a3 100644 --- a/src/util/mdb-schema.c +++ b/src/util/mdb-schema.c @@ -18,6 +18,7 @@ /* this utility dumps the schema for an existing database */ #include "mdbtools.h" +#include "mdbver.h" int main (int argc, char **argv) @@ -34,6 +35,7 @@ main (int argc, char **argv) int opt_indexes = MDB_SHEXP_DEFAULT & MDB_SHEXP_INDEXES; int opt_relations = MDB_SHEXP_DEFAULT & MDB_SHEXP_RELATIONS; int success = 0; + int print_mdbver = 0; GOptionEntry entries[] = { { "table", 'T', 0, G_OPTION_ARG_STRING, &tabname, "Only create schema for named table", "table"}, @@ -52,6 +54,7 @@ main (int argc, char **argv) { "no-indexes", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &opt_indexes, "Don't include indexes", NULL}, { "relations", 0, 0, G_OPTION_ARG_NONE, &opt_relations, "Include foreign key constraints", NULL}, { "no-relations", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &opt_relations, "Don't include foreign key constraints", NULL}, + {"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL}, { NULL }, }; GError *error = NULL; @@ -67,6 +70,13 @@ main (int argc, char **argv) fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); exit (1); } + if (print_mdbver) { + if (argc > 1) { + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + } + fprintf(stdout,"%s\n", MDB_FULL_VERSION); + exit(argc > 1); + } setlocale(LC_CTYPE, old_locale); diff --git a/src/util/mdb-sql.c b/src/util/mdb-sql.c index a6c6fc1..3dcd75a 100644 --- a/src/util/mdb-sql.c +++ b/src/util/mdb-sql.c @@ -46,6 +46,7 @@ extern void clear_history (); #include #include "mdbsql.h" +#include "mdbver.h" void dump_results(FILE *out, MdbSQL *sql, char *delimiter); void dump_results_pp(FILE *out, MdbSQL *sql); @@ -334,6 +335,7 @@ main(int argc, char **argv) char *delimiter = NULL; int in_from_colon_r = 0; char *locale = NULL; + int print_mdbver = 0; GOptionEntry entries[] = { { "delim", 'd', 0, G_OPTION_ARG_STRING, &delimiter, "Use this delimiter.", "char"}, @@ -342,6 +344,7 @@ main(int argc, char **argv) { "no-footer", 'F', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &footers, "Don't print footer", NULL}, { "input", 'i', 0, G_OPTION_ARG_FILENAME, &filename_in, "Read SQL from specified file", "file"}, { "output", 'o', 0, G_OPTION_ARG_FILENAME, &filename_out, "Write result to specified file", "file"}, + {"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL}, { NULL }, }; GError *error = NULL; @@ -357,6 +360,13 @@ main(int argc, char **argv) fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); exit (1); } + if (print_mdbver) { + if (argc > 1) { + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + } + fprintf(stdout,"%s\n", MDB_FULL_VERSION); + exit(argc > 1); + } setlocale(LC_CTYPE, locale); if (argc > 2) { diff --git a/src/util/mdb-ver.c b/src/util/mdb-ver.c index 73b1f24..5694b87 100644 --- a/src/util/mdb-ver.c +++ b/src/util/mdb-ver.c @@ -26,12 +26,8 @@ main(int argc, char **argv) MdbHandle *mdb; int print_mdbver = 0; - /* setlocale (LC_ALL, ""); */ - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); - GOptionEntry entries[] = { - { "mdbtools", 'M', 0, G_OPTION_ARG_NONE, &print_mdbver, "Show MDBtools version", NULL}, + { "version", 'M', 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL}, { NULL }, }; GError *error = NULL; @@ -48,9 +44,11 @@ main(int argc, char **argv) } if (print_mdbver) { + if (argc > 1) { + fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr); + } fprintf(stdout,"%s\n", MDB_FULL_VERSION); - if (argc == 1) - exit(0); + exit(argc > 1); } if (argc != 2) {