summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-09-11 09:01:45 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-09-11 09:01:45 +0200
commita13c2e12d2b045c3e941c816ba599c4421443b97 (patch)
treebdb73246594ccfe8856474b405b85a3bd27c7a6c
parent857c56a495d8dfa3b65f0997123f5b517e193ded (diff)
Adapt main() to new interface_reader interfacegetter
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/main.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 8346b7c..4a0ced7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -35,7 +35,7 @@ int main(int argc, const char** argv) {
auto interface_filter_names = get_interface_names(args);
- interface_reader reader(interface_filter_names);
+ interface_reader reader;
auto error = reader.read_interfaces();
if (error.has_value()) {
@@ -43,9 +43,19 @@ int main(int argc, const char** argv) {
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;
+
+ if (interface_filter_names.empty()) {
+ 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;
+ }
+ } else {
+ for (auto name: interface_filter_names) {
+ auto interfaces_by_name = reader.get_interface_by_name(name);
+ for (interface& in: interfaces_by_name) {
+ std::cout << in.get_name() << ": " << in.get_addr().value_or("interface has no address") << std::endl;
+ }
+ }
}
return 0;