SubCommandSet.java

package net.morimekta.terminal.args;

import java.util.List;

public interface SubCommandSet<SubCommandDef> extends Arg {
    /**
     * @return Subcommands in the set ordered as declared.
     */
    List<SubCommand<? extends SubCommandDef>> getSubCommands();

    SubCommand<? extends SubCommandDef> getSubCommandByName(String name);

    ArgParser parserForSubCommand(String name);

    interface Builder<SubCommandDef> extends ArgParserBuilder {
        Builder<SubCommandDef> optionalCommand();

        Builder<SubCommandDef> defaultCommand(String name);

        Builder<SubCommandDef> add(
                SubCommand<? extends SubCommandDef> subCommand);

        default Builder<SubCommandDef> add(
                SubCommand.Builder<? extends SubCommandDef> subCommand) {
            return add(subCommand.build());
        }
    }
}