Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/* 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