Skip to content

Commit

Permalink
Fixup CLI help
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Sep 12, 2024
1 parent 6229aee commit 86c70f3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
26 changes: 26 additions & 0 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ task("runSFCLI", JavaExec::class) {
outputs.upToDateWhen { false }
}

task("printSFCliFlags", JavaExec::class) {
group = "application"
description = "Runs the SoulFire client"

mainClass = projectMainClass
classpath = sourceSets["main"].runtimeClasspath
args = listOf(
"--generate-flags"
)

jvmArgs = listOf(
"-Xmx2G",
"-XX:+EnableDynamicAgentLoading",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseG1GC",
"-XX:G1NewSizePercent=20",
"-XX:G1ReservePercent=20",
"-XX:MaxGCPauseMillis=50",
"-XX:G1HeapRegionSize=32M"
)

standardInput = System.`in`

outputs.upToDateWhen { false }
}

dependencies {
libs.bundles.bom.get().forEach { api(platform(it)) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void registerOptions(CommandLine.Model.CommandSpec targetCommandSpec) {

var propertyKey = new PropertyKey(page.getNamespace(), singleEntry.getKey());

var args = new String[]{page.getNamespace() + "-" + singleEntry.getKey()};
var args = new String[]{"--%s-%s".formatted(page.getNamespace(), singleEntry.getKey())};
var settingType = singleEntry.getType();
targetCommandSpec.addOption(
switch (settingType.getValueCase()) {
Expand Down Expand Up @@ -258,7 +258,7 @@ public <T> T set(T value) {
minPropertyKey,
clientSettingsManager,
minDescription,
min.getCliFlagsList().toArray(new String[0]),
new String[]{"--%s-%s".formatted(page.getNamespace(), min.getKey())},
min.getIntSetting()));

var max = minMaxEntry.getMax();
Expand All @@ -269,7 +269,7 @@ public <T> T set(T value) {
maxPropertyKey,
clientSettingsManager,
maxDescription,
max.getCliFlagsList().toArray(new String[0]),
new String[]{"--%s-%s".formatted(page.getNamespace(), max.getKey())},
max.getIntSetting()));
}
case VALUE_NOT_SET -> throw new IllegalStateException("Unexpected value: " + entry.getValueCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ public Integer call() {
var name =
Arrays.stream(option.names())
.map("`%s`"::formatted)
.collect(Collectors.joining(", "));
.collect(Collectors.joining(", "))
.replace("|", "\\|");
var defaultValue =
option.defaultValueString() == null
? ""
: "`%s`".formatted(option.defaultValueString());
: "`%s`"
.formatted(option.defaultValueString())
.replace("|", "\\|");
var description =
option.description() == null ? "" : String.join(", ", option.description());
option.description() == null
? ""
: String.join(", ", option.description())
.replace("|", "\\|");
System.out.printf("| %s | %s | %s |%n", name, defaultValue, description);
});
cliManager.shutdown();
Expand Down
5 changes: 2 additions & 3 deletions proto/src/main/proto/soulfire/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ message SettingEntryMinMaxPairSingle {
// Basically we only send a kv map to the server with every setting entry
string key = 1;
string uiName = 2;
repeated string cliFlags = 3;
string description = 4;
IntSetting intSetting = 5;
string description = 3;
IntSetting intSetting = 4;
}

// A paired option in the settings page
Expand Down

0 comments on commit 86c70f3

Please sign in to comment.