From 8c2cf77eae769ff655fa1bda1e38ed015200cd6c Mon Sep 17 00:00:00 2001 From: Roman Tsisyk <roman@tarantool.org> Date: Thu, 17 Aug 2017 17:05:05 +0300 Subject: [PATCH] lua: support both '-V' and '-v' options for version Finally fix compatibility with Lua 5.1 command-line options. Closes #1265 --- src/main.cc | 7 ++++--- test/box-py/args.result | 12 ++++++++++-- test/box-py/args.test.py | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main.cc b/src/main.cc index 0d306433df..fec960e961 100644 --- a/src/main.cc +++ b/src/main.cc @@ -529,7 +529,7 @@ print_help(const char *program) puts("All command line options are passed to the interpreted script."); puts("When no script name is provided, the server responds to:"); puts(" -h, --help\t\t\tdisplay this help and exit"); - puts(" -V, --version\t\t\tprint program version and exit"); + puts(" -v, --version\t\t\tprint program version and exit"); puts(" -e EXPR\t\t\texecute string 'EXPR'"); puts(" -l NAME\t\t\trequire library 'NAME'"); puts(" -i\t\t\t\tenter interactive mode after executing 'SCRIPT'"); @@ -560,15 +560,16 @@ main(int argc, char **argv) static struct option longopts[] = { {"help", no_argument, 0, 'h'}, - {"version", no_argument, 0, 'V'}, + {"version", no_argument, 0, 'v'}, {NULL, 0, 0, 0}, }; - static const char *opts = "+hVie:l:"; + static const char *opts = "+hVvie:l:"; int ch; while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) { switch (ch) { case 'V': + case 'v': print_version(); return 0; case 'h': diff --git a/test/box-py/args.result b/test/box-py/args.result index 11cc9e65a5..76e0b1066d 100644 --- a/test/box-py/args.result +++ b/test/box-py/args.result @@ -6,7 +6,7 @@ Usage: tarantool script.lua [OPTIONS] [SCRIPT [ARGS]] All command line options are passed to the interpreted script. When no script name is provided, the server responds to: -h, --help display this help and exit - -V, --version print program version and exit + -v, --version print program version and exit -e EXPR execute string 'EXPR' -l NAME require library 'NAME' -i enter interactive mode after executing 'SCRIPT' @@ -24,7 +24,7 @@ Usage: tarantool script.lua [OPTIONS] [SCRIPT [ARGS]] All command line options are passed to the interpreted script. When no script name is provided, the server responds to: -h, --help display this help and exit - -V, --version print program version and exit + -v, --version print program version and exit -e EXPR execute string 'EXPR' -l NAME require library 'NAME' -i enter interactive mode after executing 'SCRIPT' @@ -51,6 +51,14 @@ Compiler: cc C_FLAGS: flags CXX_FLAGS: flags +tarantool -v +Tarantool 1.minor.patch-<rev>-<commit> +Target: platform <build> +Build options: flags +Compiler: cc +C_FLAGS: flags +CXX_FLAGS: flags + tarantool -V Tarantool 1.minor.patch-<rev>-<commit> Target: platform <build> diff --git a/test/box-py/args.test.py b/test/box-py/args.test.py index 62bdf91c97..4019aaa996 100644 --- a/test/box-py/args.test.py +++ b/test/box-py/args.test.py @@ -21,6 +21,7 @@ sys.stdout.push_filter("CXX_FLAGS:.*", "CXX_FLAGS: flags") sys.stdout.push_filter("Compiler: .*", "Compiler: cc") server.test_option("--version") +server.test_option("-v") server.test_option("-V ") script = os.getenv("SOURCEDIR") + "/test/box-py/args.lua" -- GitLab