Skip to content

Instantly share code, notes, and snippets.

@ranjitiyer
Created August 2, 2015 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ranjitiyer/84f41ab84aa16d31c733 to your computer and use it in GitHub Desktop.
Save ranjitiyer/84f41ab84aa16d31c733 to your computer and use it in GitHub Desktop.
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
final String CREATE_STACK = "createstack";
Commands cmds = new Commands(
Command.Builder(CREATE_STACK)
.withOptions(new Options(
Option.Builder(STACK_NAME_SHORT)
.withLongOpt(STACK_NAME)
.isRequired()
.build()
))
.withHelp(new HelpFormatter()),
.build(),
Command.Builder(LIST_ARTIFACTS)
.withOptions(new Options(
Option.Builder(ALL_SHORT)
.withLongOpt(ALL_SHORT)
.isRequired()
.build()
))
.build()
Command.Builder(REMOVE_ARTIFACTS)
.withOptions(new Options(
Option.Builder(ALL_SHORT)
.withLongOpt(ALL_SHORT)
.isRequired()
.build()
))
.build()
);
CommandLine cmdLine = new DefaultParser().parse(commands);
Command rootCmd = cmdLine.getCommand();
if (rootCmd.getCmd().equals(CREATE_NEW_STACK)) {
Options options = rootCmd.getOptions();
}
if (rootCmd.hasChild()) {
Command child = cmdLine.getChild();
if (!child.hasChild()) {
Options options = child.getOptions()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment