package picocli;

import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.SystemErrRule;
import picocli.CommandLine.Command;

import static org.junit.Assert.*;

public class Issue1537Ambiguous {

    @Rule
    public SystemErrRule systemErrRule = new SystemErrRule().enableLog().muteForSuccessfulTests();

    @Command
    static class MyCommand implements Runnable {

        @Command(name = "chemical-files", aliases = "chem-formats")
        void sub() {}

        public void run() {}
    }

    @Test
    public void testExecute() {
        int exitCode = new CommandLine(new MyCommand()).execute("chem");
        assertEquals(2, exitCode);

        String expected = String.format(
            "Unmatched argument at index 0: 'chem'%n" +
            "Did you mean: chem-formats or chemical-files?%n");
        assertEquals(expected, systemErrRule.getLog());
    }

    @Test
    public void testParseArgs() {
        try {
            new CommandLine(new MyCommand()).parseArgs("chem");
            fail("expected exception");
        } catch (CommandLine.UnmatchedArgumentException ex) {
            assertEquals("Unmatched argument at index 0: 'chem'", ex.getMessage());
        }
    }
}

@@ -446,16 +446,17 @@
 iases = 
+%7B
 %22chem-fo
@@ -461,16 +461,17 @@
 formats%22
+%7D
 )%0A      
@@ -621,16 +621,51 @@
 mand()).
+setAbbreviatedOptionsAllowed(true).
 execute(
@@ -1036,16 +1036,51 @@
 mand()).
+setAbbreviatedOptionsAllowed(true).
 parseArg

update test setAbbreviatedOptionsAllowed (still cannot reproduce)