[java-shib-shared] branch main updated: Add option for parsing case-insensitively.

Scott Cantor cantor.2 at osu.edu
Wed Jun 28 14:07:10 UTC 2023


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=bc6f7e1514985bef4fca73de40cc921d433665cf

The following commit(s) were added to refs/heads/main by this push:
     new bc6f7e15 Add option for parsing case-insensitively.
bc6f7e15 is described below

commit bc6f7e1514985bef4fca73de40cc921d433665cf
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jun 28 10:07:06 2023 -0400

    Add option for parsing case-insensitively.
---
 .../net/shibboleth/shared/cli/AbstractCommandLine.java  | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/shib-cli/src/main/java/net/shibboleth/shared/cli/AbstractCommandLine.java b/shib-cli/src/main/java/net/shibboleth/shared/cli/AbstractCommandLine.java
index 61b772c5..4ef42a5d 100644
--- a/shib-cli/src/main/java/net/shibboleth/shared/cli/AbstractCommandLine.java
+++ b/shib-cli/src/main/java/net/shibboleth/shared/cli/AbstractCommandLine.java
@@ -127,6 +127,9 @@ public abstract class AbstractCommandLine<T extends CommandLineArguments> {
             return args.isANSI() ? ansicode : "";
         }
     };
+
+    /** Whether options are case-sensitive. */
+    private boolean caseSensitiveOptions = true;
     
     /** Spring context. */
     @Nullable private GenericApplicationContext applicationContext;
@@ -134,6 +137,19 @@ public abstract class AbstractCommandLine<T extends CommandLineArguments> {
     /** Optional Context initialized. */
     @Nullable private ApplicationContextInitializer<? super FilesystemGenericApplicationContext> contextInitializer;
     
+    /**
+     * Sets whether JCommander parses options case-sensitively or not.
+     * 
+     * <p>Default is true.</p>
+     * 
+     * @param flag
+     * 
+     * @since 9.0.0
+     */
+    protected void setCaseSensitiveOptions(final boolean flag) {
+        caseSensitiveOptions = flag;
+    }
+    
     /**
      * Set a context initializer.
      * 
@@ -181,6 +197,7 @@ public abstract class AbstractCommandLine<T extends CommandLineArguments> {
             final Constructor<T> construct = getArgumentClass().getConstructor();
             argObject = construct.newInstance();
             final JCommander jc = new JCommander(argObject);
+            jc.setCaseSensitiveOptions(caseSensitiveOptions);
             jc.parse(args);
             if (argObject.isHelp()) {
                 argObject.printHelp(System.out);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list