org.apache.oozie.cli
Class CLIParser

java.lang.Object
  extended by org.apache.oozie.cli.CLIParser

public class CLIParser
extends Object

Command line parser based on Apache common-cli 1.x that supports subcommands.


Nested Class Summary
 class CLIParser.Command
          Bean that represents a parsed command.
 
Constructor Summary
CLIParser(String cliName, String[] cliHelp)
          Create a parser.
 
Method Summary
 void addCommand(String command, String argsHelp, String commandHelp, org.apache.commons.cli.Options commandOptions, boolean hasArguments)
          Add a command to the parser.
 CLIParser.Command parse(String[] args)
          Parse a array of arguments into a command.
 String shortHelp()
           
 void showHelp(org.apache.commons.cli.CommandLine commandLine)
          Print the help for the parser to standard output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CLIParser

public CLIParser(String cliName,
                 String[] cliHelp)
Create a parser.

Parameters:
cliName - name of the parser, for help purposes.
cliHelp - help for the CLI.
Method Detail

addCommand

public void addCommand(String command,
                       String argsHelp,
                       String commandHelp,
                       org.apache.commons.cli.Options commandOptions,
                       boolean hasArguments)
Add a command to the parser.

Parameters:
command - comand name.
argsHelp - command arguments help.
commandHelp - command description.
commandOptions - command options.
hasArguments -

parse

public CLIParser.Command parse(String[] args)
                        throws org.apache.commons.cli.ParseException
Parse a array of arguments into a command.

Parameters:
args - array of arguments.
Returns:
the parsed Command.
Throws:
org.apache.commons.cli.ParseException - thrown if the arguments could not be parsed.

shortHelp

public String shortHelp()

showHelp

public void showHelp(org.apache.commons.cli.CommandLine commandLine)
Print the help for the parser to standard output.

Parameters:
commandLine - the command line


Copyright © 2013 Apache Software Foundation. All Rights Reserved.