SystemCall 1.1.0
See the version list below for details.
dotnet add package SystemCall --version 1.1.0
NuGet\Install-Package SystemCall -Version 1.1.0
<PackageReference Include="SystemCall" Version="1.1.0" />
paket add SystemCall --version 1.1.0
#r "nuget: SystemCall, 1.1.0"
// Install SystemCall as a Cake Addin #addin nuget:?package=SystemCall&version=1.1.0 // Install SystemCall as a Cake Tool #tool nuget:?package=SystemCall&version=1.1.0
System Call
System Call is a command-parsing .NET library inspired by Jinx and named after Sword Art Online.
It uses natural language syntax and is intended for use in command line interfaces and magic systems.
using SystemCall;
// Define commands
Command[] Commands = [
new("enhance_weapon", "enhance my {weapon}(!)"),
];
// Run commands
string? RunCommand(CommandCall Call) {
switch (Call.Command.Name) {
case "enhance_weapon":
return $"Weapon enhanced: {Call.GetArgument<string>("weapon")}";
default:
return null;
}
}
// Call commands
CommandCallParser.Interpret("Enhance my 'Sword'!", Commands, RunCommand);
Arguments are parsed as Hjson, which is a flexible superset of JSON.
Defining Commands
Commands can be defined using a format string:
Command[] Commands = [
new("enhance_weapon", "enhance my {weapon}(!)"),
];
Format strings use the following syntax:
- A sequence of tokens in brackets may be entirely omitted:
(optional tokens)
- A token in curly brackets is the name of an argument:
{username}
- A list of sequences of tokens in square brackets is a list of choices:
[vanilla, chocolate, strawberry and cream]
- Any token can be escaped with a backslash:
not a bracket \(
Alternatively, commands can be manually constructed:
Command[] Commands = [
new("enhance_weapon", [
new CommandLiteralComponent("enhance my"),
new CommandArgumentComponent("weapon"),
new CommandOptionalComponent([
new CommandLiteralComponent("!"),
]),
]),
];
Calling Commands
Commands can be parsed into a list of calls:
List<CommandCall> Calls = CommandCallParser.ParseCalls("enhance my 'Sword'!", Commands);
Alternatively, commands can be parsed and interpreted, returning the output:
string? RunCommand(CommandCall Call) {
switch (Call.Command.Name) {
case "enhance_weapon":
return $"Weapon enhanced: {Call.GetArgument<string>("weapon")}";
default:
return null;
}
}
string Output = CommandCallParser.Interpret("Enhance my 'Sword'!", Commands, RunCommand);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.