};
Parser(const argp_t *argp) : argp(argp) {
for (int i = 0; argp->options[i].key; i++) {
int key_last;
int i = 0;
while (true) {
const auto &option = argp->options[i];
const uint8_t idx = option.key - 'a';
if (!option.name && !option.key) break;
if (options[idx]) {
std::cerr << std::format("duplicate key {}\n", option.key);
throw new std::runtime_error("duplicate key");
if (!option.key) {
if ((option.options & ALIAS) == 0) {
std::cerr << "non alias without a key\n";
throw new std::runtime_error("no key");
}
if (!key_last) {
std::cerr << "no option to alias\n";
throw new std::runtime_error("no alias");
}
// TODO: connect aliases in --help
trie.insert(option.name, key_last);
} else {
if (options.count(option.key)) {
std::cerr << std::format("duplicate key {}\n", option.key);
throw new std::runtime_error("duplicate key");
}
// TODO: connect aliases in --help
if (option.name) trie.insert(option.name, option.key);
options[option.key] = &option;
key_last = option.key;
}
if (option.name) trie.insert(option.name, option.key);
options[idx] = &option;
i++;
}
}