fix(main): Correct command-line argument parsing
Resolved an issue where the `--address` and `--port` command-line arguments were being ignored due to a hardcoded IP address and an incorrect parsing loop. This commit ensures that: - The application correctly uses the address and port provided by the user. - The application exits gracefully if required arguments are missing. - The argument parsing logic is simplified and more explicit.
This commit is contained in:
parent
4f8d53fedb
commit
817caed810
11
main.cpp
11
main.cpp
@ -44,20 +44,21 @@ int main(int argc, char *argv[])
|
||||
if (!parser.isSet("address")) {
|
||||
qWarning() << "Hyperion address missing.";
|
||||
parser.showHelp();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!parser.isSet("port")) {
|
||||
qWarning() << "Hyperion port missing.";
|
||||
parser.showHelp();
|
||||
return 1;
|
||||
}
|
||||
|
||||
QHash<QString, QString> opts;
|
||||
QString optName;
|
||||
for (int i = 0; i < parser.optionNames().size(); i++) {
|
||||
optName = parser.optionNames().at(i);
|
||||
opts.insert(optName, parser.value(optName));
|
||||
for (const auto &optName : parser.optionNames()) {
|
||||
if (parser.isSet(optName)) {
|
||||
opts.insert(optName, parser.value(optName));
|
||||
}
|
||||
}
|
||||
opts.insert("address", "127.0.0.1"); // Force standard loopback IP
|
||||
|
||||
grab = new HyperionGrabber(opts);
|
||||
return qapp->exec();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user