Class CliCommand

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.PrintStream err  
      protected java.io.PrintStream out  
      protected ZooKeeper zk  
    • Constructor Summary

      Constructors 
      Constructor Description
      CliCommand​(java.lang.String cmdStr, java.lang.String optionStr)
      a CLI command with command string and options.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addToMap​(java.util.Map<java.lang.String,​CliCommand> cmdMap)
      add this command to a map.
      abstract boolean exec()  
      java.lang.String getCmdStr()
      get the string used to call this command
      java.lang.String getOptionStr()
      get the option string
      java.lang.String getUsageStr()
      get a usage string, contains the command and the options
      abstract CliCommand parse​(java.lang.String[] cmdArgs)
      parse the command arguments
      void setErr​(java.io.PrintStream err)
      Set err printStream (usable for testing)
      void setOut​(java.io.PrintStream out)
      Set out printStream (usable for testing)
      void setZk​(ZooKeeper zk)
      set the zookeeper instance
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • out

        protected java.io.PrintStream out
      • err

        protected java.io.PrintStream err
    • Constructor Detail

      • CliCommand

        public CliCommand​(java.lang.String cmdStr,
                          java.lang.String optionStr)
        a CLI command with command string and options. Using System.out and System.err for printing
        Parameters:
        cmdStr - the string used to call this command
        optionStr - the string used to call this command
    • Method Detail

      • setOut

        public void setOut​(java.io.PrintStream out)
        Set out printStream (usable for testing)
        Parameters:
        out -
      • setErr

        public void setErr​(java.io.PrintStream err)
        Set err printStream (usable for testing)
        Parameters:
        err -
      • setZk

        public void setZk​(ZooKeeper zk)
        set the zookeeper instance
        Parameters:
        zk - the ZooKeeper instance.
      • getCmdStr

        public java.lang.String getCmdStr()
        get the string used to call this command
      • getOptionStr

        public java.lang.String getOptionStr()
        get the option string
      • getUsageStr

        public java.lang.String getUsageStr()
        get a usage string, contains the command and the options
      • addToMap

        public void addToMap​(java.util.Map<java.lang.String,​CliCommand> cmdMap)
        add this command to a map. Use the command string as key.
        Parameters:
        cmdMap -
      • exec

        public abstract boolean exec()
                              throws CliException
        Returns:
        true if command has watch option, false otherwise
        Throws:
        CliException