Skip to content

Commit 155b12f

Browse files
committed
Ensure hints match the var key for aliased fields
Jaunch config fields are entered as hints to trigger the appropriate actions. For assignment fields, there is a corresponding K:V entry in the vars. Config fields can have multiple key aliases, but regardless of which is entered we always add the first "primary" alias to the vars table. We must also register the hint matching this vars entry, otherwise the vars entry will be ignored when processing the hint and the intended function will fail. With this change, this now happens correctly. Previously we were recording the hint using the actual alias, resulting in aliases not working. Closes #62
1 parent 1bd0934 commit 155b12f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/commonMain/kotlin/main.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ private fun classifyArguments(
268268
if (option.assignment == null) {
269269
// standalone option
270270
if (argVal != null) fail("Option $argKey does not accept a parameter")
271+
hints += argKey
271272
} else {
272273
// option with value assignment
273274
val v = argVal ?: if (i < inputArgs.size) inputArgs[i++] else
@@ -276,14 +277,18 @@ private fun classifyArguments(
276277
// Normalize the argument to the primary flag on the comma-separated list.
277278
// Then strip leading dashes: --class-path becomes class-path, -v becomes v, etc.
278279
var varName = option.flags.first()
280+
// We also must record a hint to say which flags are enabled.
281+
// This hint must match the var entry (with dividers as applicable)
282+
val hintName = varName
279283
while (varName.startsWith("-")) varName = varName.substring(1)
280284

281285
// Store assignment value as a variable named after the normalized argument.
282286
// E.g. if the matching supported option is `--heap,--mem=<max>|Maximum heap size`,
283287
// and `--mem 52g` is given, it will store `"52g"` for the variable `heap`.
284288
vars[varName] = v
289+
290+
hints += hintName
285291
}
286-
hints += argKey
287292
} else {
288293
// The argument is not a Jaunch one. Save it for later.
289294
if (divider < 0) {

0 commit comments

Comments
 (0)