Skip to content

Commit

Permalink
chore: rename annotations (#21)
Browse files Browse the repository at this point in the history
<!-- readthedocs-preview incendocloud start -->
----
πŸ“š Documentation preview πŸ“š:
https://incendocloud--21.org.readthedocs.build/en/21/

<!-- readthedocs-preview incendocloud end -->
  • Loading branch information
Citymonstret authored Jan 12, 2024
1 parent 64f1b11 commit 931d70b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions docs/annotations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ instance of the class that you wish to parse.
## Command Methods

Command methods are annotated methods that are used to construct and handle commands.
The method has to be annotated with a `@CommandMethod` annotation that specifies the command
The method has to be annotated with a `@Command` annotation that specifies the command
syntax.
The parsed command components are mapped to the method parameters.
The parameters may also be mapped to [injected](#injections) values, such as the command sender instance,
Expand All @@ -103,8 +103,8 @@ There are three different parts that make up the command syntax:

Examples:

- `@CommandMethod("command <string> [int]")`
- `@CommandMethod("command <string> literal|alias [int]")`
- `@Command("command <string> [int]")`
- `@Command("command <string> literal|alias [int]")`

The ordering of the method parameters does not matter, the command structure is entirely determined from the
syntax string.
Expand All @@ -123,7 +123,7 @@ The argument annotation also allows you to specify non-default parsers and sugge
You may specify the argument description through the annotation as well.

```java
@CommandMethod("command <required> [optional]")
@Command("command <required> [optional]")
public void yourCommand(
@Argument(value = "required", description = "A string") String string, // Uses a name override!
@Nullable String optional // Name is inferred, and so is @Argument!
Expand All @@ -149,11 +149,11 @@ Similarly to `@Argument`, this annotation can be used to specify suggestion prov
If a boolean parameter is annotated with `@Flag` then it will generate a presence flag.
Otherwise, it will become a value flag with the parameter type as the value type.

Flags should _not_ be annotated with `@Argument` and should not present in the `@CommandMethod` syntax.
Flags should _not_ be annotated with `@Argument` and should not present in the `@Command` syntax.

### Descriptions

`@CommandMethod` can be added to an annotated command method to set the command description.
`@Command` can be added to an annotated command method to set the command description.

You can override how the descriptions are mapped by setting replacing the description mapper:

Expand All @@ -163,14 +163,14 @@ annotationParser.descriptionMapper(string -> Description.of("blablabla " + strin

### Permissions

`@CommandPermission` can be added to a command method to set the command permission.
`@Permission` can be added to a command method to set the command permission.
Only simple string-permissions can be used.
You may use a [builder modifier](#builder-modifiers) to do more complex mappings.

### Proxies

`@ProxiedBy` can be used to generate a command proxy.
In most cases it is recommended to use multiple `@CommandMethod` annotations instead as it allows for better control
In most cases it is recommended to use multiple `@Command` annotations instead as it allows for better control
over the generated command.

## Parsers
Expand Down Expand Up @@ -318,7 +318,7 @@ annotationParser.registerPreprocessorMapper(
## Annotation Processing

If `cloud-annotations` is registered as an annotation processor then it will perform compile-time validation
of `@CommandMethod`-annotated methods.
of `@Command`-annotated methods.

### Command Containers

Expand Down
4 changes: 2 additions & 2 deletions docs/cloud-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ The annotation parser now allows you to swap out the components that make up the
**`@ExceptionHandler` methods ([#537](https://github.com/Incendo/cloud/pull/537))**
You may now use annotated methods as exception handlers.

**Repeatable `@CommandMethod` ([#541](https://github.com/Incendo/cloud/pull/541))**
`@CommandMethod` is now repeatable which allows you to define multiple commands that target the same method.
**Repeatable `@Command` ([#541](https://github.com/Incendo/cloud/pull/541))**
`@Command` is now repeatable which allows you to define multiple commands that target the same method.

**Arguments without `@Argument` ([#551](https://github.com/Incendo/cloud/pull/551))**
Command methods can skip `@Argument` when the parameter name matches the name specified in the command syntax string. This requires that the code is compiled with type parameters preserved.
Expand Down
2 changes: 1 addition & 1 deletion docs/kotlin/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ the annotated command methods and suggestion providers suspending.
The module also adds the ability to use Kotlin default values in both suspending and non-suspending methods.

```kotlin title="Example of a suspending command method"
@CommandMethod("command [argument]")
@Command("command [argument]")
suspend fun yourCommand(
argument: String = "default value"
): Unit = withContext(Dispatchers.IO) {
Expand Down

0 comments on commit 931d70b

Please sign in to comment.