Package net.morimekta.console.args
Class SubCommand<SubCommandDef>
- java.lang.Object
-
- net.morimekta.console.args.SubCommand<SubCommandDef>
-
- Type Parameters:
SubCommandDef- The sub-command instance type.
public class SubCommand<SubCommandDef> extends java.lang.ObjectSub command base class.
-
-
Constructor Summary
Constructors Constructor Description SubCommand(java.lang.String name, java.lang.String usage, boolean hidden, java.util.function.Supplier<SubCommandDef> instanceFactory, java.util.function.Function<SubCommandDef,ArgumentParser> parserFactory, java.lang.Iterable<java.lang.String> aliases)Make a single sub-command.SubCommand(java.lang.String name, java.lang.String usage, boolean hidden, java.util.function.Supplier<SubCommandDef> instanceFactory, java.util.function.Function<SubCommandDef,ArgumentParser> parserFactory, java.lang.String... aliases)Make a single sub-command.SubCommand(java.lang.String name, java.lang.String usage, java.util.function.Supplier<SubCommandDef> instanceFactory, java.util.function.Function<SubCommandDef,ArgumentParser> parserFactory, java.lang.Iterable<java.lang.String> aliases)Make a single sub-command.SubCommand(java.lang.String name, java.lang.String usage, java.util.function.Supplier<SubCommandDef> instanceFactory, java.util.function.Function<SubCommandDef,ArgumentParser> parserFactory, java.lang.String... aliases)Make a single sub-command.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>getAliases()Get the list of sub-command aliases.ArgumentParsergetArgumentParser(SubCommandDef instance)Get the sub-commands internal argument argumentParser initializes with it's own options.java.lang.StringgetName()The sub-command name.java.lang.StringgetUsage()The basic usage description.booleanisHidden()If the sub-command is hidden by default.SubCommandDefnewInstance()Instantiate the selected commands implementation.
-
-
-
Constructor Detail
-
SubCommand
public SubCommand(java.lang.String name, java.lang.String usage, java.util.function.Supplier<SubCommandDef> instanceFactory, java.util.function.Function<SubCommandDef,ArgumentParser> parserFactory, java.lang.String... aliases)Make a single sub-command.- Parameters:
name- The name of the sub-command. Must be unuque.usage- The usage string describing the sub-command.instanceFactory- The instance supplier.parserFactory- The argument parser supplier for an instance.aliases- String aliases for the sub-command. Must be uniqye.
-
SubCommand
public SubCommand(java.lang.String name, java.lang.String usage, java.util.function.Supplier<SubCommandDef> instanceFactory, java.util.function.Function<SubCommandDef,ArgumentParser> parserFactory, java.lang.Iterable<java.lang.String> aliases)Make a single sub-command.- Parameters:
name- The name of the sub-command. Must be unuque.usage- The usage string describing the sub-command.instanceFactory- The instance supplier.parserFactory- The argument parser supplier for an instance.aliases- String aliases for the sub-command. Must be uniqye.
-
SubCommand
public SubCommand(java.lang.String name, java.lang.String usage, boolean hidden, java.util.function.Supplier<SubCommandDef> instanceFactory, java.util.function.Function<SubCommandDef,ArgumentParser> parserFactory, java.lang.String... aliases)Make a single sub-command.- Parameters:
name- The name of the sub-command. Must be unuque.usage- The usage string describing the sub-command.hidden- True if the sub-command should not be visible by default.instanceFactory- The instance supplier.parserFactory- The argument parser supplier for an instance.aliases- String aliases for the sub-command. Must be uniqye.
-
SubCommand
public SubCommand(java.lang.String name, java.lang.String usage, boolean hidden, java.util.function.Supplier<SubCommandDef> instanceFactory, java.util.function.Function<SubCommandDef,ArgumentParser> parserFactory, java.lang.Iterable<java.lang.String> aliases)Make a single sub-command.- Parameters:
name- The name of the sub-command. Must be unuque.usage- The usage string describing the sub-command.hidden- True if the sub-command should not be visible by default.instanceFactory- The instance supplier.parserFactory- The argument parser supplier for an instance.aliases- String aliases for the sub-command. Must be uniqye.
-
-
Method Detail
-
getName
public java.lang.String getName()
The sub-command name.- Returns:
- The name.
-
getUsage
public java.lang.String getUsage()
The basic usage description.- Returns:
- The usage description.
-
isHidden
public boolean isHidden()
If the sub-command is hidden by default.- Returns:
- True if hidden.
-
getAliases
public java.util.List<java.lang.String> getAliases()
Get the list of sub-command aliases.- Returns:
- The aliases.
-
newInstance
public SubCommandDef newInstance()
Instantiate the selected commands implementation.- Returns:
- The new sub-command isntance.
-
getArgumentParser
public ArgumentParser getArgumentParser(SubCommandDef instance)
Get the sub-commands internal argument argumentParser initializes with it's own options.- Parameters:
instance- The instance to make parser for.- Returns:
- The argument argumentParser.
-
-