From 082b721c4fd712f12bf9b72697fac49fb3abc25c Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 2 Nov 2023 19:52:42 +0000 Subject: [PATCH] Tools: Add -h option --- tools/bufr_compare.cc | 3 ++- tools/bufr_copy.cc | 3 ++- tools/bufr_dump.cc | 3 ++- tools/bufr_filter.cc | 3 ++- tools/bufr_get.cc | 3 ++- tools/bufr_index_build.cc | 3 ++- tools/bufr_ls.cc | 3 ++- tools/bufr_set.cc | 3 ++- tools/grib_compare.cc | 3 ++- tools/grib_copy.cc | 3 ++- tools/grib_dump.cc | 3 ++- tools/grib_filter.cc | 3 ++- tools/grib_get.cc | 3 ++- tools/grib_get_data.cc | 3 ++- tools/grib_histogram.cc | 3 ++- tools/grib_index_build.cc | 3 ++- tools/grib_ls.cc | 3 ++- tools/grib_merge.cc | 3 ++- tools/grib_options.cc | 8 ++++++-- tools/grib_set.cc | 3 ++- tools/grib_to_netcdf.cc | 3 ++- 21 files changed, 46 insertions(+), 22 deletions(-) diff --git a/tools/bufr_compare.cc b/tools/bufr_compare.cc index 94da7ba2a..268d7ac8e 100644 --- a/tools/bufr_compare.cc +++ b/tools/bufr_compare.cc @@ -34,7 +34,8 @@ grib_option grib_options[] = { { "I", 0, 0, 1, 0, 0 }, { "V", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 0, 1, 0 } + { "v", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); diff --git a/tools/bufr_copy.cc b/tools/bufr_copy.cc index af1bc712c..c4c8cbf8d 100644 --- a/tools/bufr_copy.cc +++ b/tools/bufr_copy.cc @@ -44,7 +44,8 @@ grib_option grib_options[] = { { "g", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 }, { "X:", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 0, 1, 0 } + { "v", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); diff --git a/tools/bufr_dump.cc b/tools/bufr_dump.cc index 60265b085..ed5fe88b8 100644 --- a/tools/bufr_dump.cc +++ b/tools/bufr_dump.cc @@ -53,7 +53,8 @@ grib_option grib_options[] = { { "V", 0, 0, 0, 1, 0 }, { "q", 0, 0, 1, 0, 0 }, { "S:", "subset_number", "\n\t\tDump the given subset\n", 0, 1, 0 }, - { "X:", 0, 0, 0, 1, 0 } + { "X:", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, /* {"x",0,0,0,1,0} */ }; diff --git a/tools/bufr_filter.cc b/tools/bufr_filter.cc index bee0fe2da..fbabc7a76 100644 --- a/tools/bufr_filter.cc +++ b/tools/bufr_filter.cc @@ -23,7 +23,8 @@ grib_option grib_options[] = { /* {"G",0,0,0,1,0}, */ { "T:", 0, 0, 1, 0, "B" }, { "7", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 0, 1, 0 } + { "v", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = "Apply the rules defined in rules_file to each BUFR " diff --git a/tools/bufr_get.cc b/tools/bufr_get.cc index 57664a7ce..ba76afca7 100644 --- a/tools/bufr_get.cc +++ b/tools/bufr_get.cc @@ -27,7 +27,8 @@ grib_option grib_options[] = { /* {"G",0,0,0,1,0}, */ { "T:", 0, 0, 1, 0, "B" }, { "7", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 1, 0, 0 } + { "v", 0, 0, 1, 0, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = diff --git a/tools/bufr_index_build.cc b/tools/bufr_index_build.cc index 12dcf7bf5..ac29bd6b7 100644 --- a/tools/bufr_index_build.cc +++ b/tools/bufr_index_build.cc @@ -34,7 +34,8 @@ grib_option grib_options[] = { { "N", 0, "Do not compress index." "\n\t\tBy default the index is compressed to remove keys with only one value.\n", - 0, 1, 0 } + 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; static int compress_index; diff --git a/tools/bufr_ls.cc b/tools/bufr_ls.cc index f86319e22..4537cc666 100644 --- a/tools/bufr_ls.cc +++ b/tools/bufr_ls.cc @@ -30,7 +30,8 @@ grib_option grib_options[] = { { "P", 0, 0, 1, 0, 0 }, { "T:", 0, 0, 1, 0, "B" }, { "7", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 1, 0, 0 } + { "v", 0, 0, 1, 0, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = diff --git a/tools/bufr_set.cc b/tools/bufr_set.cc index 38c41dd1b..40c51547b 100644 --- a/tools/bufr_set.cc +++ b/tools/bufr_set.cc @@ -35,7 +35,8 @@ grib_option grib_options[] = { /* {"G",0,0,0,1,0}, */ { "T:", 0, 0, 1, 0, "B" }, { "f", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 0, 1, 0 } + { "v", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = diff --git a/tools/grib_compare.cc b/tools/grib_compare.cc index 800c3eca6..a538f2a8c 100644 --- a/tools/grib_compare.cc +++ b/tools/grib_compare.cc @@ -34,7 +34,8 @@ grib_option grib_options[] = { { "I", 0, 0, 1, 0, 0 }, { "V", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 0, 1, 0 } + { "v", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); diff --git a/tools/grib_copy.cc b/tools/grib_copy.cc index ccc4c690a..349a32259 100644 --- a/tools/grib_copy.cc +++ b/tools/grib_copy.cc @@ -48,7 +48,8 @@ grib_option grib_options[] = { { "G", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 }, { "X:", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 0, 1, 0 } + { "v", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); diff --git a/tools/grib_dump.cc b/tools/grib_dump.cc index f61c6597e..c7e0c02d9 100644 --- a/tools/grib_dump.cc +++ b/tools/grib_dump.cc @@ -31,7 +31,8 @@ grib_option grib_options[] = { { "p:", "key1,key2,...", "\n\t\tDeclaration of keys to dump. Only those keys are dumped (not the whole message).\n", 0, 1, 0 }, { "X:", 0, 0, 0, 1, 0 }, - { "x", 0, 0, 0, 1, 0 } + { "x", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = "Dump the content of a GRIB file in different formats."; diff --git a/tools/grib_filter.cc b/tools/grib_filter.cc index 8ed7ff296..019fc48c8 100644 --- a/tools/grib_filter.cc +++ b/tools/grib_filter.cc @@ -24,7 +24,8 @@ grib_option grib_options[] = { { "G", 0, 0, 0, 1, 0 }, { "T:", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 0, 1, 0 } + { "v", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = "Apply the rules defined in rules_file to each GRIB " diff --git a/tools/grib_get.cc b/tools/grib_get.cc index 12acb78da..6251c436f 100644 --- a/tools/grib_get.cc +++ b/tools/grib_get.cc @@ -32,7 +32,8 @@ grib_option grib_options[] = { { "7", 0, 0, 0, 1, 0 }, { "v", 0, 0, 1, 0, 0 }, { "X:", 0, 0, 0, 1, 0 }, - { "i:", 0, 0, 0, 1, 0 } + { "i:", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = diff --git a/tools/grib_get_data.cc b/tools/grib_get_data.cc index 83b87421d..54185ac61 100644 --- a/tools/grib_get_data.cc +++ b/tools/grib_get_data.cc @@ -31,7 +31,8 @@ grib_option grib_options[] = { { "G", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 }, { "X:", 0, 0, 0, 1, 0 }, - { "V", 0, 0, 0, 1, 0 } + { "V", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = diff --git a/tools/grib_histogram.cc b/tools/grib_histogram.cc index a41105c74..789cdcc26 100644 --- a/tools/grib_histogram.cc +++ b/tools/grib_histogram.cc @@ -15,7 +15,8 @@ grib_option grib_options[] = { { "V", 0, 0, 0, 1, 0 }, { "p:", 0, 0, 0, 1, 0 }, /* print keys */ { "S", 0, 0, 1, 0, 0 }, /* needed for skip */ - { "w:", 0, 0, 0, 1, 0 } /* 'where' clause */ + { "w:", 0, 0, 0, 1, 0 }, /* 'where' clause */ + { "h", 0, 0, 0, 1, 0 }, }; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); diff --git a/tools/grib_index_build.cc b/tools/grib_index_build.cc index 5d1d16915..6e933da2b 100644 --- a/tools/grib_index_build.cc +++ b/tools/grib_index_build.cc @@ -33,7 +33,8 @@ grib_option grib_options[] = { { "N", 0, "Do not compress index." "\n\t\tBy default the index is compressed to remove keys with only one value.\n", - 0, 1, 0 } + 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; static int compress_index; diff --git a/tools/grib_ls.cc b/tools/grib_ls.cc index 0193b3e17..2be9333e4 100644 --- a/tools/grib_ls.cc +++ b/tools/grib_ls.cc @@ -35,7 +35,8 @@ grib_option grib_options[] = { { "7", 0, 0, 0, 1, 0 }, { "v", 0, 0, 1, 0, 0 }, { "X:", 0, 0, 0, 1, 0 }, - { "x", 0, 0, 0, 1, 0 } + { "x", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = diff --git a/tools/grib_merge.cc b/tools/grib_merge.cc index 8e18e54ea..7848935ff 100644 --- a/tools/grib_merge.cc +++ b/tools/grib_merge.cc @@ -56,7 +56,8 @@ grib_option grib_options[] = { { "g", 0, 0, 0, 1, 0 }, { "G", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 0, 1, 0 } + { "v", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); diff --git a/tools/grib_options.cc b/tools/grib_options.cc index 475f22fdf..3d792ca4e 100644 --- a/tools/grib_options.cc +++ b/tools/grib_options.cc @@ -106,8 +106,8 @@ static grib_options_help grib_options_help_list[] = { { "k:", "key1,key2,...", "\n\t\tSpecify a list of keys to index on. By default the input files are indexed on the MARS keys." "\n\t\tFor each key a string (key:s) or a double (key:d) or an integer (key:i)" - "\n\t\ttype can be requested.\n" } - + "\n\t\ttype can be requested.\n" }, + { "h", 0, "Display this help text and exit.\n" } }; static int grib_options_help_count = sizeof(grib_options_help_list) / sizeof(grib_options_help); @@ -198,6 +198,10 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g int has_input_extra = 0, nfiles = 0; char *karg = NULL, *warg = NULL, *sarg = NULL, *barg = NULL; + if (grib_options_on("h")) { + usage(); + } + if (grib_options_on("V")) { printf("\necCodes Version "); grib_print_api_version(stdout); diff --git a/tools/grib_set.cc b/tools/grib_set.cc index 13adcde65..537eb8a9f 100644 --- a/tools/grib_set.cc +++ b/tools/grib_set.cc @@ -39,7 +39,8 @@ grib_option grib_options[] = { { "G", 0, 0, 0, 1, 0 }, { "T:", 0, 0, 0, 1, 0 }, { "f", 0, 0, 0, 1, 0 }, - { "v", 0, 0, 0, 1, 0 } + { "v", 0, 0, 0, 1, 0 }, + { "h", 0, 0, 0, 1, 0 }, }; const char* tool_description = diff --git a/tools/grib_to_netcdf.cc b/tools/grib_to_netcdf.cc index e62b69a7d..b46145123 100644 --- a/tools/grib_to_netcdf.cc +++ b/tools/grib_to_netcdf.cc @@ -3936,7 +3936,8 @@ grib_option grib_options[] = { "\n\t\tChunking strategy based on GRIB message.\n", 0, 1, "6" }, { "s", 0, "Shuffle data before deflation compression.\n", 0, 1, 0 }, - { "u:", "dimension", "\n\t\tSet dimension to be an unlimited dimension.\n", 0, 1, "time" } + { "u:", "dimension", "\n\t\tSet dimension to be an unlimited dimension.\n", 0, 1, "time" }, + { "h", 0, 0, 0, 1, 0 }, }; int grib_options_count = sizeof(grib_options) / sizeof(grib_option);