Commits


Christian Hudon authored and Micah Kornfield committed dfc14ef24ed
ARROW-2260: [C++][Plasma] Use Gflags for command-line parsing The following patch ads Gflags support to `plasma-store-server`, leaves out the backtraces on invalid command-line options, and generally tries to make the error messages more useful in terms of nudging the user in the right direction. Now, calling `plasma-store-server` alone prints `plasma-store-server: please specify socket for incoming connections with -s, and the amount of memory (in bytes) to use with -m`. Likewise with `-h`, although that's a happy coincidence (`-h` was already assigned to turn on hugepage support, and the command-line parsing errors on the missing mandatory options before getting to that). Calling `plasma-store-server -help` produces: ``` plasma-store-server: Shared-memory server for Arrow data. Usage: Flags from ../src/plasma/store.cc: -d (directory where to create the memory-backed file) type: string default: "/tmp" -e (endpoint for external storage service, where objects evicted from Plasma store can be written to, optional) type: string default: "" -h (whether to enable hugepage support) type: bool default: false -m (amount of memory in bytes to use for Plasma store, required) type: string default: "" -s (socket name where the Plasma store will listen for requests, required) type: string default: "" Flags from /tmp/gflags-20190105-85639-1w01usg/gflags-2.2.2/src/gflags.cc: -flagfile (load flags from file) type: string default: "" -fromenv (set flags from the environment [use 'export FLAGS_flag1=value']) type: string default: "" -tryfromenv (set flags from the environment if present) type: string default: "" -undefok (comma-separated list of flag names that it is okay to specify on the command line even if the program does not define a flag with that name. IMPORTANT: flags in this list that have arguments MUST use the flag=value format) type: string default: "" Flags from /tmp/gflags-20190105-85639-1w01usg/gflags-2.2.2/src/gflags_completions.cc: -tab_completion_columns (Number of columns to use in output for tab completion) type: int32 default: 80 -tab_completion_word (If non-empty, HandleCommandLineCompletions() will hijack the process and attempt to do bash-style command line flag completion on this value.) type: string default: "" Flags from /tmp/gflags-20190105-85639-1w01usg/gflags-2.2.2/src/gflags_reporting.cc: -help (show help on all flags [tip: all flags can have two dashes]) type: bool default: false currently: true -helpfull (show help on all flags -- same as -help) type: bool default: false -helpmatch (show help on modules whose name contains the specified substr) type: string default: "" -helpon (show help on the modules named by this flag value) type: string default: "" -helppackage (show help on all modules in the main package) type: bool default: false -helpshort (show help on only the main module for this program) type: bool default: false -helpxml (produce an xml version of help) type: bool default: false -version (show version and build info and exit) type: bool default: false ``` which is rather verbose, but at least does the job. Outstanding questions: - Is there a way to ask Gflags to suppress all that other stuff? Or do we ditch Gflags and go back to `getopt()` but with a handcrafted help option and message? Or is this good enough? - I'm assuming we want to be as backward compatible as possible? Otherwise I'd be tempted to move the non-optional command-line options to arguments, and maybe leave `-h` for help. - In the name of being as backward-compatible as possible, I'm exiting with -1 if the external store directory is not empty, but with 1 for other usage errors? Was that worth the tiny bit of complexity to preserve that behavior? - Which version define do I use to report `plasma-store-server`'s version? - Any comments on the description of "Shared-memory server for Arrow data.", or is that good? Closes #7025 from chrish42/plasma-store-to-gflags Authored-by: Christian Hudon <chrish@pianocktail.org> Signed-off-by: Micah Kornfield <emkornfield@gmail.com>