47 static void printHelp(std::ostream &os,
const std::string &command)
50 os << command <<
" [<args>]\n";
52 os <<
"-h, --help Show this help and exit\n";
53 os <<
"-f name=<name> Filter by name\n";
54 os <<
"-f serial=<serial> Filter by serial number\n";
55 os <<
"-f mac=<mac> Filter by MAC address\n";
56 os <<
"-f iface=<mac> Filter by interface name\n";
57 os <<
"-f model=<model> Filter by model name\n";
58 os <<
"-y Assume 'yes' for all queries\n";
61 int runReconnect(
const std::string &command,
int argc,
char **argv)
69 std::string p=argv[i++];
81 catch (
const std::invalid_argument &ex)
83 std::cerr << ex.what() << std::endl;
88 else if (p ==
"-h" || p ==
"--help")
95 std::cerr <<
"Invalid argument: " << p <<
'\n';
101 if (device_filter.mac.empty() &&
102 device_filter.name.empty() &&
103 device_filter.serial.empty())
105 std::cerr <<
"No filter set" << std::endl;
114 std::cout <<
"No device found" << std::endl;
118 std::cout <<
"Reconnecting the following devices:\n";
123 std::cout <<
"Are you sure? [y/N] ";
125 std::getline(std::cin, answer);
126 if (answer !=
"y" && answer !=
"Y")
128 std::cout <<
"Cancel" << std::endl;
133 for (
const auto &device : devices)
139 std::cout <<
"Done" << std::endl;