fix: clean magic value, and update if-else to switch (#8848)

* fix: clean magic value, and update if-else to switch

* fix: return the (String args[])

* review

---------

Co-authored-by: jiejc1 <jiejc1@lenovo.com>
Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com>
This commit is contained in:
cheng102e 2026-01-28 12:45:11 +08:00 committed by GitHub
parent 75db42bca6
commit 062b98a51e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 14 deletions

View File

@ -210,7 +210,6 @@ public class Client {
public void runClient(String[] args) {
try {
Protocol protocol = parseOptions(args);
if (protocol == Protocol.NONE)
return;
@ -299,21 +298,28 @@ public class Client {
private Protocol parseOptions(String[] args) {
String protocolName = (args.length > 0) ? args[0] : "";
Protocol protocol = Protocol.NONE;
Protocol protocol;
Option[] options;
if (protocolName.equals("vnc")) {
protocol = Protocol.VNC;
options = join(commonOptions, vncOptions);
} else if (protocolName.equals("rdp")) {
protocol = Protocol.RDP;
options = join(commonOptions, rdpOptions);
} else if (protocolName.equals("hyperv")) {
protocol = Protocol.HYPERV;
options = join(commonOptions, hyperVOptions);
} else {
help();
return Protocol.NONE;
try {
protocol = Protocol.valueOf(protocolName);
} catch (IllegalArgumentException e) {
protocol = Protocol.NONE;
}
switch (protocol) {
case VNC:
options = join(commonOptions, vncOptions);
break;
case RDP:
options = join(commonOptions, rdpOptions);
break;
case HYPERV:
options = join(commonOptions, hyperVOptions);
break;
default:
help();
return Protocol.NONE;
}
// Parse all options for given protocol