mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2025-01-02 18:28:33 +01:00
Improved CLI help page formatting
This commit is contained in:
parent
6ff8f62aca
commit
66f62534c3
@ -17,15 +17,18 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.viaproxy.cli;
|
package net.raphimc.viaproxy.cli;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import joptsimple.BuiltinHelpFormatter;
|
import joptsimple.BuiltinHelpFormatter;
|
||||||
import joptsimple.OptionDescriptor;
|
import joptsimple.OptionDescriptor;
|
||||||
import joptsimple.internal.Classes;
|
import joptsimple.internal.Classes;
|
||||||
import joptsimple.internal.Strings;
|
import joptsimple.internal.Strings;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BetterHelpFormatter extends BuiltinHelpFormatter {
|
public class BetterHelpFormatter extends BuiltinHelpFormatter {
|
||||||
|
|
||||||
public BetterHelpFormatter() {
|
public BetterHelpFormatter() {
|
||||||
super(80, 2);
|
super(120, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -40,4 +43,20 @@ public class BetterHelpFormatter extends BuiltinHelpFormatter {
|
|||||||
return !Strings.isNullOrEmpty(indicator) && !String.class.getName().equals(indicator) ? Classes.shortNameOf(indicator) : "String";
|
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.formatHelpWith(new BetterHelpFormatter());
|
||||||
this.optionParser.printHelpOn(Logger.SYSOUT);
|
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);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user