Adding app version display
[samplevnf.git] / common / vnf_common / config_parse.c
index eeb547e..48921f4 100644 (file)
@@ -30,6 +30,7 @@
 #include <rte_string_fns.h>
 
 #include "app.h"
+#include "version.h"
 #include "parser.h"
 
 /**
@@ -201,8 +202,8 @@ struct app_pipeline_params default_pipeline_params = {
 };
 
 static const char app_usage[] =
-       "Usage: %s [-f CONFIG_FILE] [-s SCRIPT_FILE] [-p PORT_MASK] "
-       "[-l LOG_LEVEL] [--preproc PREPROCESSOR] [--preproc-args ARGS]\n"
+       "Usage: %s [--version] [-f CONFIG_FILE] [-s SCRIPT_FILE] [-p PORT_MASK] "
+       "[-l LOG_LEVEL] [--disable-hw-csum] [--preproc PREPROCESSOR] [--preproc-args ARGS]\n"
        "\n"
        "Arguments:\n"
        "\t-f CONFIG_FILE: Default config file is %s\n"
@@ -210,6 +211,7 @@ static const char app_usage[] =
                "config file when not provided)\n"
        "\t-s SCRIPT_FILE: No CLI script file is run when not specified\n"
        "\t-l LOG_LEVEL: 0 = NONE, 1 = HIGH PRIO (default), 2 = LOW PRIO\n"
+       "\t--version application version\n"
        "\t--disable-hw-csum Disable TCP/UDP HW checksum\n"
        "\t--preproc PREPROCESSOR: Configuration file pre-processor\n"
        "\t--preproc-args ARGS: Arguments to be passed to pre-processor\n"
@@ -3231,7 +3233,7 @@ app_config_args(struct app_params *app, int argc, char **argv)
 {
        const char *optname;
        int opt, option_index;
-       int f_present, s_present, p_present, l_present;
+       int f_present, s_present, p_present, l_present, v_present;
        int preproc_present, preproc_params_present, disable_csum_present;
        int hwlb_present;
        int flow_dir_present;
@@ -3243,6 +3245,7 @@ app_config_args(struct app_params *app, int argc, char **argv)
                { "preproc-args", 1, 0, 0 },
                { "hwlb", 1, 0, 0 },
                { "flow_dir", 0, 0, 0 },
+               { "version", 0, 0, 0 },
                { NULL,  0, 0, 0 }
        };
 
@@ -3252,6 +3255,7 @@ app_config_args(struct app_params *app, int argc, char **argv)
        f_present = 0;
        s_present = 0;
        p_present = 0;
+       v_present = 0;
        l_present = 0;
        disable_csum_present = 0;
        preproc_present = 0;
@@ -3261,7 +3265,7 @@ app_config_args(struct app_params *app, int argc, char **argv)
        flow_dir_present = 0;
 
 
-       while ((opt = getopt_long(argc, argv, "f:s:p:l:", lgopts,
+       while ((opt = getopt_long(argc, argv, "f:v:s:p:l:", lgopts,
                        &option_index)) != EOF)
                switch (opt) {
                case 'f':
@@ -3332,6 +3336,15 @@ app_config_args(struct app_params *app, int argc, char **argv)
                case 0:
                        optname = lgopts[option_index].name;
 
+                       if (strcmp(optname, "version") == 0) {
+                         if (v_present)
+                                 rte_panic("Error: VERSION is provided "
+                                         "more than once\n");
+                          v_present = 1;
+                          printf("Version: %s\n", VERSION_STR);
+                          exit(0);
+                       }
+
                        if (strcmp(optname, "hwlb") == 0) {
                                if (hwlb_present)
                                        rte_panic("Error: hwlb argument "