Comments (2)
I've implemented a class-based command system in another project. An example command is as follows:
public class TestCommand : ICommand
{
public IEnumerable<string> Aliases => new[] { "t2" };
public string Description => "A test command.";
public bool Hidden => false;
public string Name => "test2";
public IEnumerable<Parameter> Parameters => new[]
{
new Parameter("RequiredMultiple", ParameterType.MultiRequired, typeof(int[]), 4),
new Parameter("Optional", ParameterType.Optional, typeof(string))
};
public Response Execute(CommandContext context)
{
Console.WriteLine("TEST COMMAND DEFAULT FALLBACK");
return new Response("TEST COMMAND DEFAULT FALLBACK");
}
public Response Execute(CommandContext context, int[] required, string optional = null)
{
Console.WriteLine("TEST COMMAND REAL CALLBACK");
Console.WriteLine($"{string.Join(" ", required)} {optional ?? "null"}");
return new Response("TEST COMMAND REAL CALLBACK");
}
}
ICommand
requires one Execute(CommandContext context)
method to be present. Further execute methods must be manually added to match the parameter types specified in the command's Parameters
enumerable.
When the command is run, the handler converts the provided string arguments into the required types for the command.
Eg test 1 2 3 4 test1
would output '1 2 3 4 test1' to the console.
test 1 2 3 4
would output '1 2 3 4 null' to the console.
test a 1 b 2 test
would cause an error.
from orion-core.
Closing this -- we will revisit this in TShock.
from orion-core.
Related Issues (20)
- What blocks TShock 5? HOT 6
- Prepare a presentation on Orion API HOT 1
- AAA: Users and Accounts HOT 1
- Orion Framework: Internal Message Queue HOT 10
- Patch CVE-2018-1000210.
- Discussion: Current State of Orion HOT 10
- Discussion: How to handle events HOT 2
- Orion v1.4 Development Progress
- Orion v1.4 "Meta" Progress
- Terraria Projectiles HOT 1
- Terraria Tiles HOT 1
- Automated Documentation HOT 1
- Terraria World HOT 1
- Terraria Tile Entities
- Terraria Packet Definitions
- Improve event infrastructure HOT 1
- Scheduling
- Separate out implementations into launcher HOT 4
- Introduce Liquid structure.
- Interview partners for research about communication in GitHub projects wanted HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orion-core.