This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 4b3e5e6  PARQUET-1426: [C++] parquet-dump-schema has poor usability
4b3e5e6 is described below

commit 4b3e5e66b879dde53c83fb747b8fa86310b13d7d
Author: Deepak Majeti <[email protected]>
AuthorDate: Mon Oct 8 10:06:22 2018 -0400

    PARQUET-1426: [C++] parquet-dump-schema has poor usability
    
    Author: Deepak Majeti <[email protected]>
    
    Closes #2715 from majetideepak/PARQUET-1426 and squashes the following 
commits:
    
    a94387d77 <Deepak Majeti> PARQUET-1426:  Improve parquet-dump-schema 
usability
---
 cpp/tools/parquet/parquet-dump-schema.cc | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/cpp/tools/parquet/parquet-dump-schema.cc 
b/cpp/tools/parquet/parquet-dump-schema.cc
index 1e0239b..7b6c1b1 100644
--- a/cpp/tools/parquet/parquet-dump-schema.cc
+++ b/cpp/tools/parquet/parquet-dump-schema.cc
@@ -15,13 +15,38 @@
 // specific language governing permissions and limitations
 // under the License.
 
+#include <getopt.h>
 #include <iostream>
 
 #include "parquet/api/reader.h"
 #include "parquet/api/schema.h"
 
 int main(int argc, char** argv) {
-  std::string filename = argv[1];
+  static struct option options[] = {
+    {"help", no_argument, nullptr, 'h'}
+  };
+  bool help_flag = false;
+  int opt_index;
+  do {
+    opt_index = getopt_long(argc, argv, "h", options, nullptr);
+    switch (opt_index) {
+    case '?':
+    case 'h':
+      help_flag = true;
+      opt_index = -1;
+      break;
+    }
+  } while (opt_index != -1);
+  argc -= optind;
+  argv += optind;
+
+  if (argc != 1 || help_flag) {
+    std::cerr << "Usage: parquet-dump-schema [-h] [--help]"
+              << " <filename>" << std::endl;
+    return -1;
+  }
+
+  std::string filename = argv[0];
 
   try {
     std::unique_ptr<parquet::ParquetFileReader> reader =

Reply via email to