Skip to content

Commit

Permalink
better cmdl_help()
Browse files Browse the repository at this point in the history
  • Loading branch information
gitgjogh committed Jan 23, 2016
1 parent fe210d3 commit e057ae4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions libsim/sim_opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ int cmdl_parse_str (cmdl_iter_t *iter, void* dst, cmdl_act_t act, cmdl_opt_t *
{
xprint("'%s", *((char **)dst));
}
else if (act == CMDL_ACT_HELP)
{
xlprint(iter->layer + 1, "-%s <%%s>{%d} \t(ref)\n", opt->names, opt->narg);
}

return 0;
}
Expand All @@ -497,6 +501,10 @@ int cmdl_parse_strcpy(cmdl_iter_t *iter, void* dst, cmdl_act_t act, cmdl_opt_t *
{
xprint("'%s'", *((char **)dst));
}
else if (act == CMDL_ACT_HELP)
{
xlprint(iter->layer + 1, "-%s <%%s>{%d} \t(cpy)\n", opt->names, opt->narg);
}

return 0;
}
Expand All @@ -523,6 +531,10 @@ int cmdl_parse_int (cmdl_iter_t *iter, void* dst, cmdl_act_t act, cmdl_opt_t *
{
xprint("'%d'", *((int*)dst));
}
else if (act == CMDL_ACT_HELP)
{
xlprint(iter->layer + 1, "-%s <%%d>{%d}\n", opt->names, opt->narg);
}

return 0;
}
Expand Down Expand Up @@ -893,9 +905,8 @@ int cmdl_help(cmdl_iter_t *iter, void* null, int optc, cmdl_opt_t optv[])
for (i=0; i<optc; ++i)
{
cmdl_opt_t *opt = &optv[i];
xlprint(iter->layer, "-%s, {%d}, help='%s', default='%s';\n",
opt->names, opt->narg, opt->help,
SAFE_STR(opt->default_val, "") );
xlprint(iter->layer, "-%s, [%s], \t%s\n",
opt->names, SAFE_STR(opt->default_val, ""), SAFE_STR(opt->help, ""));

opt->parse(iter, 0, CMDL_ACT_HELP, opt);

Expand Down

0 comments on commit e057ae4

Please sign in to comment.