Package org.apache.zookeeper.cli
Class CliCommand
java.lang.Object
org.apache.zookeeper.cli.CliCommand
- Direct Known Subclasses:
AddAuthCommand,AddWatchCommand,CloseCommand,CreateCommand,DeleteAllCommand,DeleteCommand,DelQuotaCommand,GetAclCommand,GetAllChildrenNumberCommand,GetCommand,GetConfigCommand,GetEphemeralsCommand,ListQuotaCommand,LsCommand,ReconfigCommand,RemoveWatchesCommand,SetAclCommand,SetCommand,SetQuotaCommand,StatCommand,SyncCommand,VersionCommand,WhoAmICommand
base class for all CLI commands
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCliCommand(String cmdStr, String optionStr) a CLI command with command string and options. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToMap(Map<String, CliCommand> cmdMap) add this command to a map.abstract booleanexec()get the string used to call this commandget the option stringget a usage string, contains the command and the optionsabstract CliCommandparse the command argumentsvoidsetErr(PrintStream err) Set err printStream (usable for testing)voidsetOut(PrintStream out) Set out printStream (usable for testing)voidset the zookeeper instance
-
Field Details
-
zk
-
out
-
err
-
-
Constructor Details
-
CliCommand
a CLI command with command string and options. Using System.out and System.err for printing- Parameters:
cmdStr- the string used to call this commandoptionStr- the string used to call this command
-
-
Method Details
-
setOut
Set out printStream (usable for testing)- Parameters:
out-
-
setErr
Set err printStream (usable for testing)- Parameters:
err-
-
setZk
set the zookeeper instance- Parameters:
zk- the ZooKeeper instance.
-
getCmdStr
get the string used to call this command -
getOptionStr
get the option string -
getUsageStr
get a usage string, contains the command and the options -
addToMap
add this command to a map. Use the command string as key.- Parameters:
cmdMap-
-
parse
parse the command arguments- Parameters:
cmdArgs-- Returns:
- this CliCommand
- Throws:
CliParseException
-
exec
- Returns:
- true if command has watch option, false otherwise
- Throws:
CliException
-