package picocli;

import org.junit.Test;
import picocli.CommandLine;
import picocli.CommandLine.*;

import static org.junit.Assert.*;
import static picocli.CommandLine.ScopeType.INHERIT;

/**
 * https://github.com/remkop/picocli/issues/1774
 */
public class Issue1774 {
    public CommandLine getTestCommandLine(ParentTestCommand parentCommand, TestCommand testCommand, CommandLine.IFactory factory) {
        CommandLine commandLine = new CommandLine(parentCommand, factory);
        commandLine.addSubcommand(testCommand);
        return commandLine;
    }
    @Command(name = "parentTestCommand", mixinStandardHelpOptions = true, scope = INHERIT)
    static class ParentTestCommand {
    }

    @Command(name = "parentTestCommand", mixinStandardHelpOptions = true, scope = INHERIT,
            subcommands = TestCommand.class)
    static class ParentTestCommand2 {
    }

    @Command(name = "test")
    class TestCommand {
        @Command(name = "subcommand")
        void start(@Option(names = "-r", arity = "0") boolean optionR,
                   @Option(names = "-s", arity = "0") boolean optionS,
                   @Parameters(arity = "1") String url) {
            System.out.printf("optionR=%s, optionS=%s, url=%s%n", optionR, optionS, url);
        }
    }
    @Test
    public void testIssue1774() {
        CommandLine commandLine = getTestCommandLine(new ParentTestCommand(), new TestCommand(), CommandLine.defaultFactory());
        assertEquals(0, commandLine.execute("test", "subcommand", "-r", "-s", "URL"));
    }
}

@@ -712,189 +712,8 @@
  = %22
-parentTestCommand%22, mixinStandardHelpOptions = true, scope = INHERIT,%0A            subcommands = TestCommand.class)%0A    static class ParentTestCommand2 %7B%0A    %7D%0A%0A    @Command(name = %22
 test
@@ -718,16 +718,23 @@
 st%22)%0A   
+ static
  class T

test cleanup