@ThreadSafe public final class CommandUtils extends Object
Command
.Modifier and Type | Method and Description |
---|---|
static void |
checkNumOfArgsEquals(Command cmd,
org.apache.commons.cli.CommandLine cl,
int n)
Checks the number of non-option arguments equals n for command.
|
static void |
checkNumOfArgsNoLessThan(Command cmd,
org.apache.commons.cli.CommandLine cl,
int n)
Checks the number of non-option arguments is no less than n for command.
|
static void |
checkNumOfArgsNoMoreThan(Command cmd,
org.apache.commons.cli.CommandLine cl,
int n)
Checks the number of non-option arguments is no more than n for command.
|
static Map<String,Command> |
loadCommands(String pkgName,
Class[] classArgs,
Object[] objectArgs)
Get instances of all subclasses of
Command in a sub-package called "command" the given
package. |
public static Map<String,Command> loadCommands(String pkgName, Class[] classArgs, Object[] objectArgs)
Command
in a sub-package called "command" the given
package.pkgName
- package prefix to look inclassArgs
- type of args to instantiate the classobjectArgs
- args to instantiate the classpublic static void checkNumOfArgsEquals(Command cmd, org.apache.commons.cli.CommandLine cl, int n) throws InvalidArgumentException
cmd
- command instancecl
- parsed commandline argumentsn
- an integerInvalidArgumentException
- if the number does not equal npublic static void checkNumOfArgsNoLessThan(Command cmd, org.apache.commons.cli.CommandLine cl, int n) throws InvalidArgumentException
cmd
- command instancecl
- parsed commandline argumentsn
- an integerInvalidArgumentException
- if the number is smaller than npublic static void checkNumOfArgsNoMoreThan(Command cmd, org.apache.commons.cli.CommandLine cl, int n) throws InvalidArgumentException
cmd
- command instancecl
- parsed commandline argumentsn
- an integerInvalidArgumentException
- if the number is greater than nCopyright © 2023. All Rights Reserved.