/*
 * This file is part of the Cliche project, licensed under MIT License.
 * See LICENSE.txt file in root folder of Cliche sources.
 */

package com.maxifier.cliche;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotation for commands. Allows to specify the name of a command, otherwise method's name is used.
 * @author ASG
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Command {
    /**
     * Allows to override default command name, which is derived from method's name
     * @return "" or null if default name is used, user-specified name otherwise.
     */
    String name() default ""; // if "" then Null is assumed.

    /**
     * Specify the description of the command. Default description (if this
     * property is not set) says "methodName(Arg1Type, Arg2Type,...) : ReturnType".
     * @return command's description or "" if not set.
     */
    String description() default "";

    /**
     * Specify the shortcut name for the command.
     * If not set, if the name attribute is not set as well, the Shell takes
     * the first letter of each word (void selectUser() --- select-user --- su).
     * @return command's abbreviation or "" if not set.
     */
    String abbrev() default "";

    /**
     * Specify the string to output before command's output, i.e. some explanations.
     * @return command's header or "" if not set.
     */
    String header() default "";
}

@@ -161,16 +161,59 @@
 liche;%0A%0A
+import jline.console.completer.Completer;%0A%0A
 import j
@@ -245,16 +245,16 @@
 ntType;%0A
-
 import j
@@ -364,16 +364,39 @@
 .Target;
+%0Aimport java.util.List;
 %0A%0A/**%0A *
@@ -495,16 +495,19 @@
 s used.%0A
+ *%0A
  * @auth
@@ -701,16 +701,23 @@
 's name%0A
+     *%0A
      * @
@@ -1028,16 +1028,23 @@
 nType%22.%0A
+     *%0A
      * @
@@ -1352,16 +1352,23 @@
 -- su).%0A
+     *%0A
      * @
@@ -1549,16 +1549,23 @@
 ations.%0A
+     *%0A
      * @
@@ -1606,32 +1606,32 @@
 ot set.%0A     */%0A
-
     String heade
@@ -1646,10 +1646,496 @@
 ult %22%22;%0A
+%0A    /**%0A     * Specify the Class which will implement auto-complete logic. The class should return list of possible options by terms.%0A     *%0A     * @return command's header or %22%22 if not set.%0A     */%0A    Class%3C? extends Completer%3E completer() default DEFAULT_COMPLETER.class;%0A%0A    static final class DEFAULT_COMPLETER implements Completer %7B%0A        @Override%0A        public int complete(String buffer, int cursor, List%3CCharSequence%3E candidates) %7B%0A            return 0;%0A        %7D%0A    %7D%0A%0A
 %7D%0A

Add completer to command so that auto-completing jline logic can be defined for each command