Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static ReportConfiguration parseCommands(final File workingDirectory, fin
CommandLine commandLine;
try {
commandLine = DefaultParser.builder().setDeprecatedHandler(DeprecationReporter.getLogReporter())
.setAllowPartialMatching(true).build().parse(opts, args);
.setAllowPartialMatching(true).get().parse(opts, args);
} catch (ParseException e) {
DefaultLog.getInstance().error(e.getMessage());
DefaultLog.getInstance().error("Please use the \"--help\" option to see a list of valid commands and options.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public void verifyAllOptionsListed() {

for (Option option : opts.getOptions()) {
if (option.getOpt() != null) {
TextUtils.assertContains("-" + option.getOpt() + (option.getLongOpt() == null ? " " : ","), result);
TextUtils.assertContains(option, "-" + option.getOpt() + (option.getLongOpt() == null ? " " : ","), result);
}
if (option.getLongOpt() != null) {
TextUtils.assertContains("--" + option.getLongOpt() + " ", result);
TextUtils.assertContains(option, "--" + option.getLongOpt() + " ", result);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.regex.Pattern;

import org.apache.commons.cli.Option;
import org.apache.commons.io.IOUtils;

/**
Expand Down Expand Up @@ -78,6 +80,18 @@ public static void assertContains(final String find, final String target) {
.isTrue();
}

/**
* Asserts that a string is contained within another string and allows to print the related option.
* @param option The current option to search in via parameter find.
* @param find The string to find.
* @param target The string to search.
*/
public static void assertContains(final Option option, final String find, final String target) {
assertThat(target.contains(find)).as(() ->
format("Target option '%s' is not properly found in the text: %s%n%s", option, find, target))
.isTrue();
}

/**
* Asserts that a string is contained exactly a specified number of times within another string.
* @param times The number of times to find the string in the target.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ agnostic home for software distribution comprehension and audit tools.
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.8.0</version>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Loading