From f1e29375281c44b805749fedd8c861464e830166 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 7 Apr 2023 10:37:15 +0200 Subject: [PATCH] ArgumentParser: Parse short value arguments --- libos/src/ArgumentParser.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libos/src/ArgumentParser.cpp b/libos/src/ArgumentParser.cpp index 6f40619f..3e26b8d3 100644 --- a/libos/src/ArgumentParser.cpp +++ b/libos/src/ArgumentParser.cpp @@ -115,11 +115,29 @@ Result> 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) {