+ if (o->alias)
+ printf("%20s: %s\n", "alias", o->alias);
+
+ printf("%20s: %s\n", "type", typehelp[o->type]);
+ printf("%20s: %s\n", "default", o->def ? o->def : "no default");
+ show_option_range(o);
+ show_option_values(o);
+}
+
+static struct fio_option *find_child(struct fio_option *options,
+ struct fio_option *o)
+{
+ struct fio_option *__o;
+
+ for (__o = options + 1; __o->name; __o++)
+ if (__o->parent && !strcmp(__o->parent, o->name))
+ return __o;
+
+ return NULL;
+}
+
+static void print_option(struct fio_option *o, struct fio_option *org,
+ int level)
+{
+ char name[256], *p;
+
+ if (!o)
+ return;
+ if (!org)
+ org = o;
+
+ p = name;
+ if (level)
+ p += sprintf(p, "%s", " ");
+
+ sprintf(p, "%s", o->name);
+
+ printf("%-24s: %s\n", name, o->help);
+ print_option(find_child(o, org), org, level + 1);
+}
+
+int show_cmd_help(struct fio_option *options, const char *name)
+{
+ struct fio_option *o, *closest;
+ unsigned int best_dist;
+ int found = 0;
+ int show_all = 0;
+
+ if (!name || !strcmp(name, "all"))
+ show_all = 1;
+
+ closest = NULL;
+ best_dist = -1;
+ for (o = &options[0]; o->name; o++) {
+ int match = 0;
+
+ if (name) {
+ if (!strcmp(name, o->name) ||
+ (o->alias && !strcmp(name, o->alias)))
+ match = 1;
+ else {
+ unsigned int dist;
+
+ dist = string_distance(name, o->name);
+ if (dist < best_dist) {
+ best_dist = dist;
+ closest = o;
+ }
+ }
+ }