mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Add the platform-neutral command api for module tooling
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.
This commit is contained in:
1 parent
480e5485ac
commit
fc81e54b0c
16 files changed
+874
-5
No files matched your search
@@ -0,0 +1,33 @@
|
||||
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();
|
||||
}
|
||||
Reference in new issue
Block a user