Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Despical committed Sep 21, 2024
1 parent a537d89 commit ba77e79
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
TimeUnit timeUnit() default TimeUnit.SECONDS;

/**
* If option is true, console will be affected by
* If option is {@code true}, console will be affected by
* confirmations; otherwise, it will override the
* confirmation period to use the command again.
*
Expand Down
34 changes: 32 additions & 2 deletions src/main/java/me/despical/commandframework/annotations/Flag.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,53 @@
import java.lang.annotation.Target;

/**
* Annotation to specify flags for command arguments.
* This annotation can be used multiple times on the same method.
*
* <p>The {@code value()} method holds the list of flags, and the
* {@code prefix()} method defines the default prefix for the flags,
* which is {@code --} by default.</p>
*
* <p>The {@link FlagContainer} is a container annotation that allows
* the {@link Flag} annotation to be repeatable on methods.</p>
*
* @author Despical
* <p>
* Created at 20.09.2024
* <p>Created at 20.09.2024</p>
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Flag.FlagContainer.class)
public @interface Flag {

/**
* Specifies the list of flag values.
*
* @return an array of flag values
*/
String[] value();

/**
* Specifies the prefix for the flags. Default is "--".
*
* @return the flag prefix
*/
String prefix() default "--";

/**
* Container annotation for holding multiple {@link Flag} annotations
* on the same method.
*
* <p>Used internally by the {@link Repeatable} annotation.</p>
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@interface FlagContainer {

/**
* Holds an array of {@link Flag} annotations.
*
* @return an array of {@link Flag} annotations
*/
Flag[] value();
}
}
56 changes: 54 additions & 2 deletions src/main/java/me/despical/commandframework/annotations/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,81 @@
import java.lang.annotation.Target;

/**
* Annotation to define options for command arguments.
* This annotation can be used multiple times on the same method.
*
* <p>The {@code value()} method represents the key of the option,
* and the {@code prefix()} method defines the default prefix for options,
* which is {@code --} by default.</p>
*
* <p>Additional separators can be customized using the {@code valueSeparator()}
* and {@code keySeparator()} methods. By default, the value separator is
* a comma ({@code ,}), and the key separator is an equals sign ({@code =}).
* The {@code allowSeparating()} method controls whether separating values
* is allowed, with the default set to {@code true}.</p>
*
* <p>The {@link OptionContainer} is a container annotation that allows
* the {@link Option} annotation to be repeatable on methods.</p>
*
* @author Despical
* <p>
* Created at 20.09.2024
* <p>Created at 20.09.2024</p>
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Option.OptionContainer.class)
public @interface Option {

/**
* Specifies the key of the option.
*
* @return the option key
*/
String value();

/**
* Specifies the prefix for the options. Default is "--".
*
* @return the option prefix
*/
String prefix() default "--";

/**
* Specifies the separator used between values. Default is a comma ",".
*
* @return the value separator
*/
String valueSeparator() default ",";

/**
* Specifies the separator between key and value. Default is "=".
*
* @return the key-value separator
*/
String keySeparator() default "=";

/**
* Determines whether separating multiple values is allowed.
* Default is {@code true}.
*
* @return {@code true} if separating is allowed, {@code false} otherwise
*/
boolean allowSeparating() default true;

/**
* Container annotation for holding multiple {@link Option} annotations
* on the same method.
*
* <p>Used internally by the {@link Repeatable} annotation.</p>
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@interface OptionContainer {

/**
* Holds an array of {@link Option} annotations.
*
* @return an array of {@link Option} annotations
*/
Option[] value();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.despical.commandframework.annotations.Flag;
import me.despical.commandframework.annotations.Option;
import org.jetbrains.annotations.ApiStatus;

import java.lang.reflect.Method;
import java.util.*;
Expand All @@ -12,6 +13,7 @@
* <p>
* Created at 20.09.2024
*/
@ApiStatus.Internal
public class OptionParser {

private final Flag[] flags;
Expand Down

0 comments on commit ba77e79

Please sign in to comment.