diff --git a/README.md b/README.md index affda23..a7fae3f 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,7 @@ Options: --yac-method Use YAC interpolation with specific method; click the method button in the GUI to cycle methods at runtime --yac-3d Fractional fill-value masking for 3D variables + -v, --version Show version -h, --help Show help message ``` @@ -283,6 +284,7 @@ Options (uterm): --yac Use YAC interpolation (default: avg_arith) --yac-method Use YAC interpolation method (requires WITH_YAC=1) --yac-3d Fractional fill-value masking for 3D variables + -v, --version Show version -h, --help Show help ``` diff --git a/src/us_types.h b/src/us_types.h index 596d6a5..d509678 100644 --- a/src/us_types.h +++ b/src/us_types.h @@ -9,6 +9,9 @@ #include +/* Version */ +#define USHOW_VERSION "0.1.3" + /* Constants */ #define EARTH_RADIUS_M 6371000.0 #define DEG2RAD (M_PI / 180.0) diff --git a/src/ushow.c b/src/ushow.c index 2508f4e..3c41815 100644 --- a/src/ushow.c +++ b/src/ushow.c @@ -793,6 +793,7 @@ static void print_usage(const char *prog) { fprintf(stderr, " --light Use light theme (default: dark)\n"); fprintf(stderr, " -t, --threads Max threads\n"); fprintf(stderr, " (default: OMP_NUM_THREADS or 4)\n"); + fprintf(stderr, " -v, --version Show version\n"); fprintf(stderr, " -h, --help Show this help\n"); fprintf(stderr, "\nExamples:\n"); fprintf(stderr, " %s data.nc # Single file\n", prog); @@ -834,12 +835,13 @@ static int parse_options(int argc, char **argv, int *first_data_arg) { #endif {"light", no_argument, 0, OPT_LIGHT}, {"threads", required_argument, 0, 't'}, + {"version", no_argument, 0, 'v'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; int opt; - while ((opt = getopt_long(argc, argv, "m:r:i:d:pt:h", long_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "m:r:i:d:pt:vh", long_options, NULL)) != -1) { switch (opt) { case 'm': strncpy(options.mesh_file, optarg, MAX_NAME_LEN - 1); @@ -915,6 +917,9 @@ static int parse_options(int argc, char **argv, int *first_data_arg) { options.user_threads = nt; break; } + case 'v': + printf("ushow %s\n", USHOW_VERSION); + return 1; case 'h': print_usage(argv[0]); return 1; diff --git a/src/uterm.c b/src/uterm.c index 776f04d..fbcd3e8 100644 --- a/src/uterm.c +++ b/src/uterm.c @@ -260,6 +260,7 @@ static void print_usage(const char *prog) { #endif fprintf(stderr, " -t, --threads Max threads\n"); fprintf(stderr, " (default: OMP_NUM_THREADS or 4)\n"); + fprintf(stderr, " -v, --version Show version\n"); fprintf(stderr, " -h, --help Show this help\n\n"); fprintf(stderr, "Keys:\n"); @@ -888,12 +889,13 @@ static int parse_options(int argc, char **argv, int *first_data_arg) { {"yac-3d", no_argument, 0, OPT_YAC_3D}, #endif {"threads", required_argument, 0, 't'}, + {"version", no_argument, 0, 'v'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; int opt; - while ((opt = getopt_long(argc, argv, "m:r:i:d:t:h", long_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "m:r:i:d:t:vh", long_options, NULL)) != -1) { switch (opt) { case 'm': strncpy(options.mesh_file, optarg, MAX_NAME_LEN - 1); @@ -909,6 +911,9 @@ static int parse_options(int argc, char **argv, int *first_data_arg) { options.frame_delay_ms = atoi(optarg); if (options.frame_delay_ms < 10) options.frame_delay_ms = 10; break; + case 'v': + printf("uterm %s\n", USHOW_VERSION); + return 1; case 'h': print_usage(argv[0]); return 1;