args: Add --dump option
This exposes the --dump option to the user.
The parser would ignore arguments that do not take an option. This
ensures they are added to the arguments returned to the application.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Change-Id: I22e8899a21f7f494fc9af757967a318730207503
diff --git a/args.cpp b/args.cpp
index 673b080..e210b42 100644
--- a/args.cpp
+++ b/args.cpp
@@ -15,11 +15,12 @@
namespace args
{
-static constexpr auto shortForm = "v:f:o:h";
+static constexpr auto shortForm = "v:f:o:dh";
static const option longForm[] = {
{"vpd", required_argument, nullptr, 'v'},
{"fru", required_argument, nullptr, 'f'},
{"object", required_argument, nullptr, 'o'},
+ {"dump", no_argument, nullptr, 'd'},
{"help", no_argument, nullptr, 'h'},
{0, 0, 0, 0},
};
@@ -30,6 +31,7 @@
std::cerr << "args:\n";
std::cerr << "--vpd=<vpd file> pathname of file containing vpd,";
std::cerr << " for eg an eeprom file\n";
+ std::cerr << "--dump output contents of parsed VPD\n";
std::cerr << "--fru=<FRU type>, supported types:\n";
std::cerr << "\t"
<< "bmc\n";
@@ -81,6 +83,11 @@
}
args.emplace(which->name, std::move(values));
}
+ else
+ {
+ // Add options that do not have arguments to the arglist
+ args.emplace(which->name, std::vector<std::string>{});
+ }
}
}