Github user jlm429 commented on the issue:

    https://github.com/apache/commons-cli/pull/14
  
    fwiw - this is what I had to fix ... probably better off not digging around 
in the default parser though if not needed :0
    
        private void handleShortAndLongOption(String token) throws 
ParseException
        {
            String t = Util.stripLeadingHyphens(token);
    
            int pos = t.indexOf('=');
    
            if (t.length() == 1)
            {
                // -S
                if (options.hasShortOption(t))
                {
                    handleOption(options.getOption(t));
                }
                else
                {
                    handleUnknownToken(token);
                }
            }
            else if (pos == -1)
            {
                // no equal sign found (-xxx)
                if (options.hasShortOption(t))
                {
                    handleOption(options.getOption(t));
                }
                else if (!options.getMatchingOptions(t).isEmpty())
                {
                    // -L or -l
                    handleLongOptionWithoutEqual(token);
                }
                else
                {
                    // look for a long prefix (-Xmx512m)
                    String opt = getLongPrefix(t);
    
                    if (opt != null && options.getOption(opt).acceptsArg())
                    {
                        handleOption(options.getOption(opt));
                        
currentOption.addValueForProcessing(t.substring(opt.length()));
                        currentOption = null;
                    }
                    else if (isJavaProperty(t))
                    {
                        // -SV1 (-Dflag)
                        handleOption(options.getOption(t.substring(0, 1)));
                        currentOption.addValueForProcessing(t.substring(1));
                        currentOption = null;
                    }
                    else
                    {
                        // -S1S2S3 or -S1S2V
                        handleConcatenatedOptions(token);
                    }
                }
            }
            else
            {
                // equal sign found (-xxx=yyy)
                String opt = t.substring(0, pos);
                String value = t.substring(pos + 1);
    
                //check if equal is in argument (-option"test=arg")
                // -L=V
                if (opt.length()>1 && !options.hasOption(opt))
                {
                    //Search for long option and use correct option/argument if 
found
                    String newOpt=getLongPrefix(opt);
                    if (newOpt!=null)
                    {
                      pos = newOpt.length();
                      opt = t.substring(0, pos);
                      value = t.substring(pos);
                    }
                    //check if equal is in argument (-o"test=arg") and use 
correct short option if found
                    // -S=V
                    else if (options.hasOption(opt.substring(0,1)) && 
!opt.substring(1,2).contains("="))
                    {
                     opt = t.substring(0, 1);
                     value = t.substring(1);
                   }
                }
    
    
    
    
                if (opt.length() == 1)
                {
                    // -S=V
                    Option option = options.getOption(opt);
                    if (option != null && option.acceptsArg())
                    {
                        handleOption(option);
                        currentOption.addValueForProcessing(value);
                        currentOption = null;
                    }
                    else
                    {
                        handleUnknownToken(token);
                    }
                }
                else if (isJavaProperty(opt))
                {
                    // -SV1=V2 (-Dkey=value)
                    handleOption(options.getOption(opt.substring(0, 1)));
                    currentOption.addValueForProcessing(opt.substring(1));
                    currentOption.addValueForProcessing(value);
                    currentOption = null;
                }
                else
                {
                    // -L=V or -l=V
                    handleLongOptionWithEqual(token);
                }
            }
        }



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to