From d1db0e98dc071fda46d6fb8ecbfdfc8251555e04 Mon Sep 17 00:00:00 2001 From: Olmo Kramer Date: Thu, 14 Sep 2023 11:08:21 +0200 Subject: [PATCH 1/2] Allow passing multiple options in the "Advanced" group By default, `picocli` sets `exclusive = true` on `ArgGroup`s, which means that it is not allowed to pass multiple options within the group [1]. [1] https://picocli.info/#_mutually_exclusive_options --- cli/src/main/java/de/jplag/cli/CliOptions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/main/java/de/jplag/cli/CliOptions.java b/cli/src/main/java/de/jplag/cli/CliOptions.java index 573707b86..c55e71f3b 100644 --- a/cli/src/main/java/de/jplag/cli/CliOptions.java +++ b/cli/src/main/java/de/jplag/cli/CliOptions.java @@ -53,7 +53,7 @@ public class CliOptions implements Runnable { "--result-directory"}, description = "Name of the directory in which the comparison results will be stored (default: result)%n") public String resultFolder = "results"; - @ArgGroup(heading = "Advanced%n") + @ArgGroup(heading = "Advanced%n", exclusive = false) public Advanced advanced = new Advanced(); @ArgGroup(validate = false, heading = "Clustering%n") From 36dae0ffca407d2d6e69d15329ad45f4805d84fa Mon Sep 17 00:00:00 2001 From: Olmo Kramer Date: Thu, 14 Sep 2023 11:33:58 +0200 Subject: [PATCH 2/2] Add test for the advanced options group --- .../java/de/jplag/cli/AdvancedGroupTest.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 cli/src/test/java/de/jplag/cli/AdvancedGroupTest.java diff --git a/cli/src/test/java/de/jplag/cli/AdvancedGroupTest.java b/cli/src/test/java/de/jplag/cli/AdvancedGroupTest.java new file mode 100644 index 000000000..bc88af731 --- /dev/null +++ b/cli/src/test/java/de/jplag/cli/AdvancedGroupTest.java @@ -0,0 +1,23 @@ +package de.jplag.cli; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; + +import org.junit.jupiter.api.Test; + +class AdvancedGroupTest extends CommandLineInterfaceTest { + private static final String SUFFIXES = ".sc,.scala"; + + private static final double SIMILARITY_THRESHOLD = 0.5; + + /** + * Verify that it is possible to set multiple options in the "advanced" options group. + */ + @Test + void testNotExclusive() throws CliException { + buildOptionsFromCLI(defaultArguments().suffixes(SUFFIXES).similarityThreshold(SIMILARITY_THRESHOLD)); + assertEquals(Arrays.stream(SUFFIXES.split(",")).toList(), options.fileSuffixes()); + assertEquals(0.5, options.similarityThreshold()); + } +}