#include "cmdl.h"
-const struct cmd *find_cmd(const struct cmd *cmds, char *str)
+static const struct cmd *find_cmd(const struct cmd *cmds, char *str)
{
const struct cmd *c;
const struct cmd *match = NULL;
return NULL;
}
+bool has_opt(struct opt *opts, char *key)
+{
+ return get_opt(opts, key) ? true : false;
+}
+
char *shift_cmdl(struct cmdl *cmdl)
{
int next;
int i;
int cnt = 0;
- for (i = cmdl->optind; i < cmdl->argc; i += 2) {
+ for (i = cmdl->optind; i < cmdl->argc; i++) {
struct opt *o;
o = find_opt(opts, cmdl->argv[i]);
cmdl->argv[i]);
return -EINVAL;
}
+ if (o->flag & OPT_KEYVAL) {
+ cmdl->optind++;
+ i++;
+ }
cnt++;
- o->val = cmdl->argv[i + 1];
- cmdl->optind += 2;
+ o->val = cmdl->argv[i];
+ cmdl->optind++;
}
return cnt;