@@ -0,0 +1,1341 @@
+package picocli.examples.autocomplete;%0A%0Aimport picocli.AutoComplete;%0Aimport picocli.CommandLine;%0Aimport picocli.CommandLine.Command;%0Aimport picocli.CommandLine.Option;%0Aimport picocli.CommandLine.Spec;%0A%0A@Command(name = %22mycommand%22, mixinStandardHelpOptions = true, version = %221.0%22,%0A        subcommands = Completion.class)%0Apublic class CommandWithCompletionSubcommand implements Runnable %7B%0A%0A    @Option(names = %7B%22-x%22, %22--x-long-option%22%7D)%0A    int x;%0A%0A    @Option(names = %7B%22-y%22, %22--y-long-option%22%7D)%0A    int y;%0A%0A    @Override%0A    public void run() %7B%0A        System.out.printf(%22x * y = %25s%25n%22, x * y);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        new CommandLine(new CommandWithCompletionSubcommand()).execute(args);%0A    %7D%0A%7D%0A%0A@Command(name = %22completion%22, mixinStandardHelpOptions = true,%0A        description = %22Generate a completion script for the parent command%22)%0Aclass Completion implements Runnable %7B%0A%0A    @Spec CommandLine.Model.CommandSpec spec;%0A%0A    @Option(names = %7B%22-n%22, %22--name%22%7D,%0A            description = %22Optionally specify the name of the command to create%22 +%0A                    %22 a completion script for, %5C%22$%7BDEFAULT-VALUE%7D%5C%22 by default.%22)%0A    String name = %22mycommand%22;%0A%0A    @Override%0A    public void run() %7B%0A        System.out.println(%0A                AutoComplete.bash(name, spec.parent().commandLine()));%0A    %7D%0A%7D%0A

Add example that outputs completion script as a subcommand in an existing command