Left justify help output
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index 79565754b804ff12880071912b4d1305b15f7c08..84a0f52ab54f025d48a0bca3a4f8650ed421a825 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -197,11 +197,11 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                const struct value_pair *vp;
                int i;
 
-               ret = 1;
                for (i = 0; i < PARSE_MAX_VP; i++) {
                        vp = &o->posval[i];
                        if (!vp->ival || vp->ival[0] == '\0')
                                break;
+                       ret = 1;
                        if (!strncmp(vp->ival, ptr, strlen(vp->ival))) {
                                ret = 0;
                                if (!o->off1)
@@ -257,10 +257,20 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                }
                break;
        }
-       case FIO_OPT_STR_STORE:
+       case FIO_OPT_STR_STORE: {
+               fio_opt_str_fn *fn = o->cb;
+
                cp = td_var(data, o->off1);
                *cp = strdup(ptr);
+               if (fn) {
+                       ret = fn(data, ptr);
+                       if (ret) {
+                               free(*cp);
+                               *cp = NULL;
+                       }
+               }
                break;
+       }
        case FIO_OPT_RANGE: {
                char tmp[128];
                char *p1, *p2;
@@ -527,9 +537,12 @@ int show_cmd_help(struct fio_option *options, const char *name)
 
                if (show_all || match) {
                        found = 1;
-                       printf("%20s: %s\n", o->name, o->help);
-                       if (show_all)
+                       if (match)
+                               printf("%20s: %s\n", o->name, o->help);
+                       if (show_all) {
+                               printf("%-20s: %s\n", o->name, o->help);
                                continue;
+                       }
                }
 
                if (!match)
@@ -579,7 +592,7 @@ void options_init(struct fio_option *options)
                }
                if (!o->cb && !o->off1)
                        fprintf(stderr, "Option %s: neither cb nor offset given\n", o->name);
-               if (o->type == FIO_OPT_STR)
+               if (o->type == FIO_OPT_STR || o->type == FIO_OPT_STR_STORE)
                        continue;
                if (o->cb && (o->off1 || o->off2 || o->off3 || o->off4))
                        fprintf(stderr, "Option %s: both cb and offset given\n", o->name);