Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: misc doc updates #18

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/annotations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,19 @@ Exceptions will be wrapped in `ArgumentParseResult.failure`.
You may create [suggestion providers](../core/index.md#suggestions) from annotated methods by using the `@Suggestions`
annotation.

The parameters of the method must be `CommandContext<C> context, String input` but the return type can be an iterable
The parameters of the method must be `CommandContext<C> context, String input`
or `CommandContext<C> context, CommandInput input` but the return type can be an iterable
(or stream) of suggestion objects, or strings.

```java title="Example signatures"
@Suggestions("name")
public List<String> suggestions(CommandContext<C> context, String input) { /* ... */ }
public List<String> suggestions(CommandContext<C> context, CommandInput input) { /* ... */ }

@Suggestions("name")
public Stream<String> suggestions(CommandContext<C> context, String input) { /* ... */ }

@Suggestions("name")
public Set<Suggestion> suggestions(CommandContext<C> context, String input) { /* ... */ }
public Set<Suggestion> suggestions(CommandContext<C> context, CommandInput input) { /* ... */ }

@Suggestions("name")
public Iterable<String> suggestions(CommandContext<C> context, String input) { /* ... */ }
Expand Down
22 changes: 16 additions & 6 deletions docs/core/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ You may provide your own suggestions using a suggestion provider.
### Execution coordinators

The execution coordinator is responsible for coordinating command parsing and execution.
Cloud ships with two different command execution coordinators:
You may create a simple execution coordinator by using `ExecutionCoordinator.simple()` which will not
Citymonstret marked this conversation as resolved.
Show resolved Hide resolved
enforce any particular executor and both parsing and suggestion generation will take place on the calling
thread unless the parser or suggestion provider redirects to another executor.

- **SimpleCommandExecutionCoordinator**: Performs all actions on the calling thread.
- **AsynchronousCommandExecutionCoordinator**: Uses an executor to dispatch the parsing and execution tasks.
You can change the default executor, and also force command parsing to take place on the calling thread.

You may also create your own execution coordinator by implementing `CommandExecutionCoordinator`.
You may also use `ExecutionCoordinator.asyncCoordinator()` to create an execution coordinator that will perform
parsing and suggestion generation asynchronously. You may customize the asynchronous coordinator by using
`ExecutionCoordinator.builder()` and supply different executors for different execution steps, or use
`ExecutionCoordinator.coordinatorFor(Executor)` to supply an executor which is used at every execution step.

### Building a command

Expand Down Expand Up @@ -153,6 +154,15 @@ This is done by using the `Command.Builder.senderType(Class)` method.
Cloud will make sure that the sender is of the right type when executing the command, and will fail exceptionally
if it isn't.

<!-- prettier-ignore -->
!!! example annotate "Example sender type usage"
Assume that `SubSender` extends `Sender`.

```java
Command.Builder<Sender> builder = manager.commandBuilder("command");
Command.Builder<SubSender> subBuilder = builder.senderType(SubSender.class);
```

#### Command meta

Command meta-data is used to attach key-value pairs to the commands, which may then be used by different components
Expand Down
Loading