mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
A module registers a root Command through ToolingRegistry.registerCommand: typed Arguments (word, text, integer, decimal, flag, choice, resource, registered), sub-commands, and a CommandAction that runs against a CommandContext with a ToolPack, a Sender and the platform's registries. ToolPack.edit is the one way to change pack files; ObjectCodec reads and writes the host's object format. The host catalogues the root commands and fails a pack load when two modules claim one root name or alias, naming both.
34 lines
1.2 KiB
Java
34 lines
1.2 KiB
Java
package com.volmit.tooling;
|
|
|
|
import com.volmit.resource.PlatformRegistries;
|
|
import com.volmit.world.PackWorld;
|
|
import java.util.Optional;
|
|
|
|
/**
|
|
* One run of a command, or one completion: the arguments parsed so far, who sent it and what it runs against. Valid only
|
|
* while the action or the suggestions run.
|
|
*/
|
|
public interface CommandContext {
|
|
/**
|
|
* The value of {@code argument}, or its fallback when the sender left it out.
|
|
*
|
|
* @throws IllegalStateException when the argument is required and has no value yet, as in the suggestions of an
|
|
* argument that comes before it
|
|
*/
|
|
<T> T get(Argument<T> argument);
|
|
|
|
/** Who sent the command. */
|
|
Sender sender();
|
|
|
|
/** The pack the host resolved for this command: the one named by {@code pack=<name>}, else the pack of the sender's
|
|
* world, else the pack of the sender's open studio.
|
|
*/
|
|
ToolPack pack();
|
|
|
|
/** The world the sender stands in, when it generates with {@link #pack()}; empty for the console or another pack's world. */
|
|
Optional<PackWorld> world();
|
|
|
|
/** The platform's registries; empty when the host runs without a platform. */
|
|
Optional<PlatformRegistries> platform();
|
|
}
|