This is an automated email from the ASF dual-hosted git repository. pottlinger pushed a commit to branch fix/RAT-500 in repository https://gitbox.apache.org/repos/asf/creadur-rat.git
commit 11f0db774eb17a89d81ce48158052115a93f8d93 Author: P. Ottlinger <[email protected]> AuthorDate: Tue Oct 14 18:40:08 2025 +0200 RAT-500: Do not log exception if no arguments are provided in CLI, encourage using --help instead --- .../it/resources/ReportTest/RAT_469/verify.groovy | 30 ++++++++++------------ .../main/java/org/apache/rat/OptionCollection.java | 5 ++-- .../src/main/java/org/apache/rat/Report.java | 6 +++++ .../resources/GitIgnoreBuilderTest/verify.groovy | 2 +- src/changes/changes.xml | 6 +++-- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_469/verify.groovy b/apache-rat-core/src/it/resources/ReportTest/RAT_469/verify.groovy index 0ea02505..d59a49bb 100644 --- a/apache-rat-core/src/it/resources/ReportTest/RAT_469/verify.groovy +++ b/apache-rat-core/src/it/resources/ReportTest/RAT_469/verify.groovy @@ -1,21 +1,4 @@ package ReportTest.RAT_469 - -import org.apache.rat.testhelpers.TextUtils -import org.apache.rat.testhelpers.XmlUtils -import org.apache.rat.license.ILicenseFamily; -import org.w3c.dom.Document -import javax.xml.xpath.XPath -import javax.xml.xpath.XPathFactory - - -private static Map<String, String> mapOf(String... parts) { - Map<String, String> map = new HashMap<>() - for (int i = 0; i < parts.length; i += 2) { - map.put(parts[i], parts[i+1]) - } - return map -} - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -32,6 +15,19 @@ private static Map<String, String> mapOf(String... parts) { * See the License for the specific language governing permissions and * limitations under the License. */ +import org.apache.rat.testhelpers.XmlUtils +import org.w3c.dom.Document +import javax.xml.xpath.XPath +import javax.xml.xpath.XPathFactory + +private static Map<String, String> mapOf(String... parts) { + Map<String, String> map = new HashMap<>() + for (int i = 0; i < parts.length; i += 2) { + map.put(parts[i], parts[i+1]) + } + return map +} + output = new File(args[0]) content = output.text diff --git a/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java b/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java index c3f747dd..7a993cb9 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java +++ b/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java @@ -117,7 +117,7 @@ public final class OptionCollection { * Parses the standard options to create a ReportConfiguration. * * @param workingDirectory The directory to resolve relative file names against. - * @param args the arguments to parse + * @param args the arguments to parse. * @param helpCmd the help command to run when necessary. * @param noArgs If {@code true} then the commands do not need extra arguments. * @return a ReportConfiguration or {@code null} if Help was printed. @@ -125,6 +125,7 @@ public final class OptionCollection { */ public static ReportConfiguration parseCommands(final File workingDirectory, final String[] args, final Consumer<Options> helpCmd, final boolean noArgs) throws IOException { + Options opts = buildOptions(); CommandLine commandLine; try { @@ -157,7 +158,7 @@ public final class OptionCollection { String msg = "No directories or files specified for scanning. Did you forget to close a multi-argument option?"; DefaultLog.getInstance().error(msg); helpCmd.accept(opts); - throw new ConfigurationException(msg); + return null; } return configuration; diff --git a/apache-rat-core/src/main/java/org/apache/rat/Report.java b/apache-rat-core/src/main/java/org/apache/rat/Report.java index ff4103c4..53268589 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/Report.java +++ b/apache-rat-core/src/main/java/org/apache/rat/Report.java @@ -40,6 +40,12 @@ public final class Report { * @throws Exception on error. */ public static void main(final String[] args) throws Exception { + if (args == null || args.length == 0) { + DefaultLog.getInstance().info("Please use the \"--help\" option to see a " + + "list of valid commands and options, as you did not provide any arguments."); + System.exit(0); + } + DefaultLog.getInstance().info(new VersionInfo().toString()); ReportConfiguration configuration = OptionCollection.parseCommands(new File("."), args, Report::printUsage); if (configuration != null) { diff --git a/apache-rat-core/src/test/resources/GitIgnoreBuilderTest/verify.groovy b/apache-rat-core/src/test/resources/GitIgnoreBuilderTest/verify.groovy index 46694988..54b8f267 100644 --- a/apache-rat-core/src/test/resources/GitIgnoreBuilderTest/verify.groovy +++ b/apache-rat-core/src/test/resources/GitIgnoreBuilderTest/verify.groovy @@ -1,4 +1,4 @@ -package RAT_355 +package GitIgnoreBuilderTest import org.apache.rat.report.claim.ClaimStatistic import org.apache.rat.testhelpers.XmlUtils diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b4ffc790..769550bf 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -59,12 +59,14 @@ The <action> type attribute can be one of: <author email="[email protected]">Apache Creadur RAT developers</author> </properties> <body> - <!--release version="1.0.0-SNAPSHOT" date="xxxx-yy-zz" description="Current SNAPSHOT - release to be done"> + <release version="1.0.0-SNAPSHOT" date="xxxx-yy-zz" description="Current SNAPSHOT - release to be done"> + <action issue="RAT-500" type="fix" dev="pottlinger"> + Do not throw an exception if no arguments are provided in CLI, encourage to use --help instead. + </action> <action issue="RAT-498" type="update" dev="pottlinger" due-to="dependabot"> TODO: collect all dependabot updates for release 1.0.0. </action> </release> - --> <release version="0.17" date="2025-10-12" description= "Apart from many dependency updates and multiple bugfixes, this release brings a major harmonization among all available UIs (CLI, Apache Ant, Apache Maven) concerning parameters
