-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,065 additions
and
1,232 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,30 +10,30 @@ | |
* | ||
* @author <a href="mailto:[email protected]">Jiaqi Guo</a> | ||
*/ | ||
public abstract class ArgumentProcessorFactory | ||
{ | ||
/** | ||
* @return Instance of ArgumentProcessorFactory. The implementation is determined by {@link ServiceLoader} | ||
*/ | ||
static ArgumentProcessorFactory getInstance() | ||
{ | ||
Iterator<ArgumentProcessorFactory> factories = ServiceLoader.load( ArgumentProcessorFactory.class ).iterator(); | ||
if ( factories.hasNext() ) | ||
{ | ||
return factories.next(); | ||
} | ||
throw new AssertionError( "Can't find an implementation of " + ArgumentProcessorFactory.class.getName() | ||
+ " from service loader" ); | ||
public abstract class ArgumentProcessorFactory { | ||
/** | ||
* @return Instance of ArgumentProcessorFactory. The implementation is determined by | ||
* {@link ServiceLoader} | ||
*/ | ||
static ArgumentProcessorFactory getInstance() { | ||
Iterator<ArgumentProcessorFactory> factories = | ||
ServiceLoader.load(ArgumentProcessorFactory.class).iterator(); | ||
if (factories.hasNext()) { | ||
return factories.next(); | ||
} | ||
throw new AssertionError("Can't find an implementation of " | ||
+ ArgumentProcessorFactory.class.getName() + " from service loader"); | ||
} | ||
|
||
/** | ||
* Create new instance of {@link ArgumentProcessor}. The implementation of factory needs to implement this method to | ||
* create customized argument processor | ||
* | ||
* @param <T> Type of bean to process | ||
* @param beanType Type of bean to process | ||
* @param parser Command line parser that is aware of command line syntax | ||
* @return Instance of argument processor implementation | ||
*/ | ||
protected abstract <T> ArgumentProcessor<T> newProcessor( Class<? extends T> beanType, CommandLineParser parser ); | ||
/** | ||
* Create new instance of {@link ArgumentProcessor}. The implementation of factory needs to | ||
* implement this method to create customized argument processor | ||
* | ||
* @param <T> Type of bean to process | ||
* @param beanType Type of bean to process | ||
* @param parser Command line parser that is aware of command line syntax | ||
* @return Instance of argument processor implementation | ||
*/ | ||
protected abstract <T> ArgumentProcessor<T> newProcessor(Class<? extends T> beanType, | ||
CommandLineParser parser); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,22 +7,21 @@ | |
* | ||
* @author <a href="mailto:[email protected]">Jiaqi Guo</a> | ||
*/ | ||
public interface AutoCompletable | ||
{ | ||
/** | ||
* Suggest candidates for an option with given partial input | ||
* | ||
* @param optionName Name of option | ||
* @param partialOption Given partial input | ||
* @return List of candidates or NULL if it can't figure out | ||
*/ | ||
List<String> suggestOption( String optionName, String partialOption ); | ||
public interface AutoCompletable { | ||
/** | ||
* Suggest candidates for an option with given partial input | ||
* | ||
* @param optionName Name of option | ||
* @param partialOption Given partial input | ||
* @return List of candidates or NULL if it can't figure out | ||
*/ | ||
List<String> suggestOption(String optionName, String partialOption); | ||
|
||
/** | ||
* Suggest candidates for argument with given partial input | ||
* | ||
* @param partialArgument Partial argument input | ||
* @return List of candidates or NULL if it can't figure out | ||
*/ | ||
List<String> suggestArgument( String partialArgument ); | ||
/** | ||
* Suggest candidates for argument with given partial input | ||
* | ||
* @param partialArgument Partial argument input | ||
* @return List of candidates or NULL if it can't figure out | ||
*/ | ||
List<String> suggestArgument(String partialArgument); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,23 +7,22 @@ | |
import java.lang.annotation.Target; | ||
|
||
/** | ||
* This annotation marks a property as non-option argument or arguments. Type of this property can be array, List or | ||
* single value. | ||
* This annotation marks a property as non-option argument or arguments. Type of this property can | ||
* be array, List or single value. | ||
* | ||
* @author <a href="mailto:[email protected]">Jiaqi Guo</a> | ||
*/ | ||
@Documented | ||
@Target( { ElementType.METHOD, ElementType.FIELD } ) | ||
@Retention( RetentionPolicy.RUNTIME ) | ||
public @interface Argument | ||
{ | ||
/** | ||
* @return String description of argument which will be displayed in usage | ||
*/ | ||
String description() default ""; | ||
@Target({ElementType.METHOD, ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Argument { | ||
/** | ||
* @return String description of argument which will be displayed in usage | ||
*/ | ||
String description() default ""; | ||
|
||
/** | ||
* @return Name of argument displayed in usage | ||
*/ | ||
String displayName() default "arg"; | ||
/** | ||
* @return Name of argument displayed in usage | ||
*/ | ||
String displayName() default "arg"; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,27 +12,26 @@ | |
* @author <a href="mailto:[email protected]">Jiaqi Guo</a> | ||
*/ | ||
@Documented | ||
@Target( ElementType.TYPE ) | ||
@Retention( RetentionPolicy.RUNTIME ) | ||
public @interface Cli | ||
{ | ||
/** | ||
* @return String description of command | ||
*/ | ||
String description() default ""; | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Cli { | ||
/** | ||
* @return String description of command | ||
*/ | ||
String description() default ""; | ||
|
||
/** | ||
* @return Name of command | ||
*/ | ||
String name(); | ||
/** | ||
* @return Name of command | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* @return Note displayed as footer | ||
*/ | ||
String note() default ""; | ||
/** | ||
* @return Note displayed as footer | ||
*/ | ||
String note() default ""; | ||
|
||
/** | ||
* @return True if unexpected option or argument is expected to cause error | ||
*/ | ||
boolean restrict() default true; | ||
/** | ||
* @return True if unexpected option or argument is expected to cause error | ||
*/ | ||
boolean restrict() default true; | ||
} |
Oops, something went wrong.