Skip to content

Instantly share code, notes, and snippets.

@aneveux
Created November 6, 2013 09:49
Show Gist options
  • Save aneveux/7333539 to your computer and use it in GitHub Desktop.
Save aneveux/7333539 to your computer and use it in GitHub Desktop.
package com.acme.sample.commands;
import com.acme.sample.Messages;
import com.worldline.clic.commands.AbstractCommand;
import com.worldline.clic.commands.CommandContext;
/**
* Just an example of a command...
*
* @author aneveux
* @version 1.0
* @since 1.0
*/
public class HelloCommand extends AbstractCommand {
/**
* Allows to configure the parser and specify all the options which are
* available for the command. It allows to perform validation of all the
* command line.
*/
@Override
public void configureParser() {
parser.accepts("name")
.withRequiredArg()
.ofType(String.class)
.required();
}
/**
* Allows to deal with the command's execution...
*/
@Override
public void execute(final CommandContext context) {
context.write(Messages.HELLO.value(options.valueOf("name")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment