remove dependency on getopt in parquet tools

This commit is contained in:
Renat Valiullin committed 2019-02-01 14:32:12 -08:00
1 parent fb11322538
commit 03422aa998
1 file changed
+11 -20
+11 -20
View File
@@ -15,39 +15,30 @@
// 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) {
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;
std::string filename;
if (argc != 1 || help_flag) {
for (int i = 1; i < argc; i++) {
if (!std::strcmp(argv[i], "-?") || !std::strcmp(argv[i], "-h") ||
!std::strcmp(argv[i], "--help")) {
help_flag = true;
} else {
filename = argv[i];
}
}
if (argc != 2 || 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 =
parquet::ParquetFileReader::OpenFile(filename);