SystemCall 8.0.0

dotnet add package SystemCall --version 8.0.0
                    
NuGet\Install-Package SystemCall -Version 8.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SystemCall" Version="8.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SystemCall" Version="8.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SystemCall" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SystemCall --version 8.0.0
                    
#r "nuget: SystemCall, 8.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=SystemCall&version=8.0.0
                    
Install SystemCall as a Cake Addin
#tool nuget:?package=SystemCall&version=8.0.0
                    
Install SystemCall as a Cake Tool

System Call

NuGet

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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