}
}
argp->parser(key, arg, input);
argp->parser(key, arg, this);
}
}
// parse rest argv as normal arguments
for (i = i + 1; i < argc; i++) {
argp->parser(Key::ARG, argv[i], input);
argp->parser(Key::ARG, argv[i], this);
args++;
}
if (!args) argp->parser(Key::NO_ARGS, 0, input);
if (!args) argp->parser(Key::NO_ARGS, 0, this);
argp->parser(Key::END, 0, input);
argp->parser(Key::SUCCESS, 0, input);
argp->parser(Key::END, 0, this);
argp->parser(Key::SUCCESS, 0, this);
return 0;
unknown:
std::cerr << std::format("unknown option {}\n", argv[i]);
argp->parser(Key::ERROR, 0, input);
argp->parser(Key::ERROR, 0, this);
return 1;
missing:
std::cerr << std::format("option {} missing a value\n", argv[i]);
argp->parser(Key::ERROR, 0, input);
argp->parser(Key::ERROR, 0, this);
return 2;
excess:
std::cerr << std::format("option {} don't require a value\n", argv[i]);
argp->parser(Key::ERROR, 0, input);
argp->parser(Key::ERROR, 0, this);
return 3;
}
private:
class trie_t {
public:
~trie_t() noexcept {