diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-09-10 19:59:38 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-09-10 20:36:12 +0200 |
commit | 3f60536f66ee50f07162d6ec186c70d76566f4f6 (patch) | |
tree | db88a3025d63415fc02f1f998ec83f4e2aa58084 | |
parent | deea3540eb9322ba803961bd7adcb6f5b8527633 (diff) |
Add main() implementation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/main.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index c2208c6..8346b7c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,9 +33,21 @@ int main(int argc, const char** argv) { true, // show help if requested "getif 1.0"); // version string - for(auto const& arg : args) { - std::cout << arg.first << arg.second << std::endl; + auto interface_filter_names = get_interface_names(args); + + interface_reader reader(interface_filter_names); + + auto error = reader.read_interfaces(); + if (error.has_value()) { + std::cerr << *error << std::endl; + exit(1); // exit is okay because this is main.cpp + } + + auto ifs = reader.get_interfaces(); + for (auto it = ifs.begin(); it != ifs.end(); it++) { + std::cout << it->get_name() << ": " << it->get_addr().value_or("interface has no address") << std::endl; } return 0; } + |