ArgumentParser: Parse short value arguments

This commit is contained in:
apio 2023-04-07 10:37:15 +02:00
parent 9b8996adeb
commit f1e2937528
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -115,11 +115,29 @@ Result<Vector<StringView>> ArgumentParser::parse(int argc, char* const* argv)
{
StringView flags = &arg[1];
for (char c : flags)
for (usize j = 0; j < flags.length(); j++)
{
char c = flags[j];
bool found = false;
// FIXME: Implement value arguments for short flags.
// Last flag, this could be a value flag
if (j + 1 == flags.length())
{
for (const auto& current : m_value_args)
{
if (current.short_flag == ' ') continue;
if (current.short_flag == c)
{
current_value_argument = current;
is_parsing_value_argument = true;
found = true;
break;
}
}
if (found) continue;
}
for (const auto& current : m_switch_args)
{