From 837d546b49afaf8626b9de38b90fc63a6786090c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 10 Sep 2021 19:50:16 +0200 Subject: Add helper function to get interface names from CLI Signed-off-by: Matthias Beyer --- src/main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 092f113..c2208c6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,22 @@ R"(Usage: getif [INTERFACE ...] --version Show version. )"; +std::vector +get_interface_names(std::map& args) +{ + auto it = args.find("INTERFACE"); + if (it != args.end()) { + if (it->second.isStringList()) { + return it->second.asStringList(); + } else { + std::cerr << "Argument parsing error." << std::endl; + exit(1); // exit is okay, because this is main.cpp + } + } else { + return {}; + } +} + int main(int argc, const char** argv) { std::map args = docopt::docopt(USAGE, -- cgit v1.2.3