Skip to content

Commit

Permalink
Cli shows completion candidates in help text of enums and allows lowe…
Browse files Browse the repository at this point in the history
…rcase enum values.
  • Loading branch information
TwoOfTwelve committed Apr 17, 2024
1 parent da0c5b9 commit bef8c0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions cli/src/main/java/de/jplag/cli/options/CliOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public class CliOptions implements Runnable {
"--result-file"}, description = "Name of the file in which the comparison results will be stored (default: ${DEFAULT-VALUE}). Missing .zip endings will be automatically added.")
public String resultFile = "results";

@Option(names = {"-M",
"--mode"}, description = "The mode of JPlag: either only run analysis, only open the viewer, or do both (default: ${DEFAULT_VALUE})")
@Option(names = {"-M", "--mode"}, description = "The mode of JPlag. One of: ${COMPLETION-CANDIDATES} (default: ${DEFAULT_VALUE})")
public JPlagMode mode = JPlagMode.RUN;

@Option(names = {"--normalize"}, description = "Activate the normalization of tokens. Supported for languages: Java, C++.")
Expand Down Expand Up @@ -109,10 +108,12 @@ public static class Clustering {
public ClusteringEnabled enabled = new ClusteringEnabled();

public static class ClusteringEnabled {
@Option(names = {"--cluster-alg", "--cluster-algorithm"}, description = "Specifies the clustering algorithm (default: ${DEFAULT-VALUE}).")
@Option(names = {"--cluster-alg",
"--cluster-algorithm"}, description = "Specifies the clustering algorithm. Available algorithms: ${COMPLETION-CANDIDATES} (default: ${DEFAULT-VALUE}).")
public ClusteringAlgorithm algorithm = new ClusteringOptions().algorithm();

@Option(names = {"--cluster-metric"}, description = "The similarity metric used for clustering (default: ${DEFAULT-VALUE}).")
@Option(names = {
"--cluster-metric"}, description = "The similarity metric used for clustering. Available metrics: ${COMPLETION-CANDIDATES} (default: ${DEFAULT-VALUE}).")
public SimilarityMetric metric = new ClusteringOptions().similarityMetric();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public CliInputHandler(String[] args) {
}

private CommandLine buildCommandLine() {
CommandLine cli = new CommandLine(this.options);
CommandLine cli = new CommandLine(this.options).setCaseInsensitiveEnumValuesAllowed(true);
cli.setHelpFactory(new HelpFactory());

cli.getHelpSectionMap().put(SECTION_KEY_OPTION_LIST, help -> help.optionList().lines().map(it -> {
Expand Down

0 comments on commit bef8c0c

Please sign in to comment.