mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-14 19:15:08 -05:00
Improved CLI help page formatting
This commit is contained in:
parent
6ff8f62aca
commit
66f62534c3
2 changed files with 21 additions and 2 deletions
|
@ -17,15 +17,18 @@
|
|||
*/
|
||||
package net.raphimc.viaproxy.cli;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import joptsimple.BuiltinHelpFormatter;
|
||||
import joptsimple.OptionDescriptor;
|
||||
import joptsimple.internal.Classes;
|
||||
import joptsimple.internal.Strings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BetterHelpFormatter extends BuiltinHelpFormatter {
|
||||
|
||||
public BetterHelpFormatter() {
|
||||
super(80, 2);
|
||||
super(120, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,4 +43,20 @@ public class BetterHelpFormatter extends BuiltinHelpFormatter {
|
|||
return !Strings.isNullOrEmpty(indicator) && !String.class.getName().equals(indicator) ? Classes.shortNameOf(indicator) : "String";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String createDefaultValuesDisplay(List<?> defaultValues) {
|
||||
if (defaultValues.size() == 1) {
|
||||
Object value = defaultValues.get(0);
|
||||
if (value instanceof ProtocolVersion version) {
|
||||
return version.getName();
|
||||
} else if (value instanceof String) {
|
||||
return "\"" + value + "\"";
|
||||
}
|
||||
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
return defaultValues.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
|
|||
|
||||
this.optionParser.formatHelpWith(new BetterHelpFormatter());
|
||||
this.optionParser.printHelpOn(Logger.SYSOUT);
|
||||
Logger.LOGGER.info("For a more detailed explanation of the options, please refer to the viaproxy.yml file.");
|
||||
Logger.LOGGER.info("For a more detailed description of the options, please refer to the viaproxy.yml file.");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue