Skip to content

Commit 63aeb04

Browse files
committed
Improved help argument handling
1 parent 89d95b8 commit 63aeb04

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

src/main/java/net/raphimc/viaproxy/protocoltranslator/viaproxy/ViaProxyCLIConfig.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import net.lenni0451.optconfig.CLIConfigLoader;
2222
import net.lenni0451.optconfig.ConfigContext;
2323
import net.lenni0451.optconfig.ConfigLoader;
24-
import net.lenni0451.optconfig.annotations.CheckSuperclasses;
25-
import net.lenni0451.optconfig.annotations.OptConfig;
26-
import net.lenni0451.optconfig.annotations.Option;
24+
import net.lenni0451.optconfig.annotations.*;
2725
import net.lenni0451.optconfig.cli.HelpOptions;
2826
import net.lenni0451.optconfig.cli.UnknownOption;
2927
import net.lenni0451.optconfig.exceptions.CLIIncompatibleOptionException;
@@ -41,10 +39,19 @@ public class ViaProxyCLIConfig extends ViaProxyConfig {
4139

4240
private ConfigContext<ViaProxyCLIConfig> configContext;
4341

42+
@Hidden
4443
@Option("help")
44+
@Description("Displays a help message with a list of all available options")
4545
private boolean help = false;
4646

47+
@Hidden
48+
@Option("extended-help")
49+
@Description("Displays an extended help message with detailed descriptions of the options")
50+
private boolean extendedHelp = false;
51+
52+
@Hidden
4753
@Option("list-versions")
54+
@Description("Lists all supported backend server versions and exits")
4855
private boolean listVersions = false;
4956

5057
public static ViaProxyCLIConfig create(final File configFile) {
@@ -63,10 +70,10 @@ public void loadFromArguments(final String[] args) {
6370
// ViaProxy.EVENT_MANAGER.call(new PreOptionsParseEvent(optionParser));
6471

6572
final List<UnknownOption> unknownOptions = cliConfigLoader.loadCLIOptions(args, true);
66-
if (this.help) {
73+
if (this.help || this.extendedHelp) {
6774
throw new HelpRequestedException();
6875
} else if (this.listVersions) {
69-
Logger.LOGGER.info("=== Supported Server Versions ===");
76+
Logger.LOGGER.info("=== Supported backend server versions ===");
7077
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
7178
Logger.LOGGER.info(version.getName());
7279
}
@@ -88,8 +95,10 @@ public void loadFromArguments(final String[] args) {
8895
} catch (HelpRequestedException ignored) {
8996
}
9097

91-
cliConfigLoader.printCLIHelp(Logger.SYSOUT, HelpOptions.DEFAULT/*.withShowDepends(false).withShowDescription(false).withSort(true).withShowBooleanType(false).withQuoteStrings(true)*/);
92-
Logger.LOGGER.info("For a more detailed description of the options, please refer to the viaproxy.yml file.");
98+
cliConfigLoader.printCLIHelp(Logger.SYSOUT, HelpOptions.DEFAULT.withShowDescription(this.extendedHelp).withShowDepends(false).withShowBooleanType(true));
99+
if (!this.extendedHelp) {
100+
Logger.LOGGER.info("For a more detailed description of the options, use --extended-help or refer to the viaproxy.yml file.");
101+
}
93102
System.exit(1);
94103
}
95104

0 commit comments

Comments
 (0)