mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-23 12:06:06 +01:00
Made version parsing more lenient and improved CLI error handling
This commit is contained in:
parent
a0e1732bb9
commit
353b1301e8
@ -84,13 +84,14 @@ public class ViaProxy {
|
||||
}
|
||||
try {
|
||||
transformerManager.hookInstrumentation(Agents.getInstrumentation());
|
||||
injectedMain("Runtime Agent", args);
|
||||
} catch (Throwable t) {
|
||||
final InjectionClassLoader injectionClassLoader = new InjectionClassLoader(transformerManager, ClassLoaders.getSystemClassPath());
|
||||
injectionClassLoader.setPriority(EnumLoaderPriority.PARENT_FIRST);
|
||||
Thread.currentThread().setContextClassLoader(injectionClassLoader);
|
||||
Methods.invoke(null, Methods.getDeclaredMethod(injectionClassLoader.loadClass(ViaProxy.class.getName()), "injectedMain", String.class, String[].class), "Injection ClassLoader", args);
|
||||
return;
|
||||
}
|
||||
injectedMain("Runtime Agent", args);
|
||||
}
|
||||
|
||||
public static void injectedMain(final String injectionMethod, final String[] args) throws InterruptedException, IOException {
|
||||
|
@ -85,13 +85,7 @@ public class Options {
|
||||
final OptionSet options;
|
||||
try {
|
||||
options = parser.parse(args);
|
||||
} catch (OptionException e) {
|
||||
Logger.LOGGER.error("Error parsing options: " + e.getMessage());
|
||||
parser.formatHelpWith(new BetterHelpFormatter());
|
||||
parser.printHelpOn(Logger.SYSOUT);
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.has(help)) {
|
||||
parser.formatHelpWith(new BetterHelpFormatter());
|
||||
parser.printHelpOn(Logger.SYSOUT);
|
||||
@ -128,6 +122,12 @@ public class Options {
|
||||
SERVER_HAPROXY_PROTOCOL = options.has(serverHaProxyProtocol);
|
||||
LEGACY_CLIENT_PASSTHROUGH = options.has(legacyClientPassthrough);
|
||||
PluginManager.EVENT_MANAGER.call(new PostOptionsParseEvent(options));
|
||||
} catch (OptionException e) {
|
||||
Logger.LOGGER.error("Error parsing options: " + e.getMessage());
|
||||
parser.formatHelpWith(new BetterHelpFormatter());
|
||||
parser.printHelpOn(Logger.SYSOUT);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,10 @@ public class VersionEnumConverter implements ValueConverter<VersionEnum> {
|
||||
for (VersionEnum version : VersionEnum.getAllVersions()) {
|
||||
if (version.getName().equalsIgnoreCase(s)) return version;
|
||||
}
|
||||
for (VersionEnum version : VersionEnum.getAllVersions()) {
|
||||
if (version.getProtocol().getIncludedVersions().contains(s)) return version;
|
||||
}
|
||||
|
||||
throw new ValueConversionException("Unable to find version '" + s + "'");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user