Skip to content

Delegate class

ancap-kun edited this page Feb 20, 2023 · 2 revisions

Delegate is, as the name implies, a command statement that will, depending on the subcommand, pass processing somewhere.

This is roughly how you can add subcommands to your command:

public class FooExecutor extends CommandTarget {

    public FooExecutor() {
        super(new Delegate(
                    new SubCommand(
                            new StringDelegatePattern( /* main argument */ "foo", /* aliases */ "foo1", "foo2"),
                            new Delegate( /* code */)
                    ),
                    new SubCommand(
                            new StringDelegatePattern("bar", "baz"),
                            new Arguments(/* code */)
                    ),
                    new SubCommand(
                            new StringDelegatePattern("ochko",)
                            new Advice(/* code */)
                    ),
        ));
    }
}
Clone this wiki locally