SystemCall 8.0.0
dotnet add package SystemCall --version 8.0.0
NuGet\Install-Package SystemCall -Version 8.0.0
<PackageReference Include="SystemCall" Version="8.0.0" />
<PackageVersion Include="SystemCall" Version="8.0.0" />
<PackageReference Include="SystemCall" />
paket add SystemCall --version 8.0.0
#r "nuget: SystemCall, 8.0.0"
#addin nuget:?package=SystemCall&version=8.0.0
#tool nuget:?package=SystemCall&version=8.0.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.
COMMAND: heal [me, everyone, player {name}] by {amount} (points)
CALL: heal player "John Doe" by 10 points
COMMAND: enhance (my) armament(!)
CALL: Enhance Armament!
Example
using SystemCall;
// Define commands
Command[] Commands = [
new("enhance_weapon", "enhance my {weapon}(!)", Call => {
return $"Weapon enhanced: {Call.GetArgument<string>("weapon")}";
}),
];
// Call commands
string.Join("\n", CommandCall.Execute("Enhance my 'Sword'!", Commands)).ShouldBe("Weapon enhanced: Sword");
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
Calls can be parsed using an input string:
List<CommandCall> Calls = CommandCall.ParseAll("enhance my 'Sword'!", Commands);
Calls use the following syntax:
- Each call is separated by newlines or semicolons:
eat me; drink me
- Any token can be escaped with a backslash:
not a bracket \(
Alternatively, calls can be parsed and executed, returning a result:
List<object?> Outputs = CommandCall.Execute("Enhance my 'Sword'!", Commands);
Arguments are parsed as JSONH, which is a superset of JSON.
If a call is ambiguous between multiple commands, the first command is prioritized.
Known Bugs/Limitations
Optional arguments must have a leading/trailing token
In the following example, object
is an optional argument:
eat ({object}) please
However, calling eat please
will not match the command.
The reason is that please
is parsed as the optional object
argument rather than the token.
This is a current limitation with the System Call parser that may be fixed in the future.
The current workaround is to add another token within the brackets:
eat (the {object}) please
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- JsonhCs (>= 1.4.0)
- LinkDotNet.StringBuilder (>= 2.4.1)
-
net9.0
- JsonhCs (>= 1.4.0)
- LinkDotNet.StringBuilder (>= 2.4.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.0 | 35 | 3/30/2025 |
7.2.0 | 429 | 3/25/2025 |
7.1.0 | 116 | 3/20/2025 |
7.0.0 | 111 | 3/19/2025 |
6.0.0 | 118 | 3/15/2025 |
5.3.0 | 102 | 3/9/2025 |
5.2.0 | 79 | 1/26/2025 |
5.1.0 | 66 | 1/25/2025 |
5.0.0 | 63 | 1/24/2025 |
4.0.0 | 64 | 1/24/2025 |
3.0.0 | 73 | 1/23/2025 |
2.1.0 | 59 | 1/17/2025 |
2.0.0 | 57 | 1/17/2025 |
1.2.0 | 81 | 11/24/2024 |
1.1.0 | 72 | 11/24/2024 |
1.0.0 | 82 | 11/13/2024 |