Created
August 2, 2015 03:41
-
-
Save ranjitiyer/84f41ab84aa16d31c733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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