Comandus 0.1.0

dotnet add package Comandus --version 0.1.0
                    
NuGet\Install-Package Comandus -Version 0.1.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="Comandus" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Comandus" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Comandus" />
                    
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 Comandus --version 0.1.0
                    
#r "nuget: Comandus, 0.1.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.
#:package Comandus@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Comandus&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Comandus&version=0.1.0
                    
Install as a Cake Tool

Comandus

Turn a short typed string into a typed set of commands.

Comandus is a cross-platform .NET library for fast data entry. An operator who issues the same kind of document many times a day (an insurance policy, an invoice, an export job) types one compact string instead of filling a form field by field. Comandus parses the string against rules you define and returns a typed list of commands; your application uses them to fill the form or run the job.

Under development. Not ready for production use until the 1.0.0 release. The API may change in any 0.x release without notice.

Examples

Input Result
AK37106207008NRGGG123 personal code 37106207008; car plate GGG123
TPVCA37106207008SUM10000E#R1GGG123 policy type VCA; personal code 37106207008; amount 100.00 EUR; risk R1; car plate GGG123
HTTPhttps://api.example.com#BD=id1SNEXCc:\temp#REPuser@example.lt HTTP sink https://api.example.com; body id1; Excel sink to c:\temp; report to user@example.lt

Spaces between tokens are allowed: AK 37106207008 NR GGG123 gives the same result.

Build from source

dotnet build Comandus.slnx
dotnet test --solution Comandus.slnx

Install

dotnet add package Comandus

Targets netstandard2.0 and net10.0. No runtime dependencies.

Usage

using Comandus;

var builder = SchemaSet.Create();
var policy = builder.Schema("ca-policy");
var personalCode = policy.Key("AK").Digits(11).Named("PersonalCode").Required();
var plate        = policy.Key("NR").Text().Named("Plate");
SchemaSet schemas = builder.Build();   // immutable, thread-safe: keep one instance

var result = schemas.Parse("AK37106207008NRGGG123");

if (result.IsComplete)
{
    form.PersonalCode = result.Get(personalCode);   // typed: no strings, no casts
    form.Plate        = result.Get(plate);
}

foreach (var d in result.Diagnostics)
    Console.WriteLine($"{d.Span} {d.State} {d.Code}: {d.Message}");

Binding in one line, by field name or [Comandus("AK")]:

var form = result.Bind<PolicyForm>();          // or result.BindTo(existingForm)
result.Apply(plate, v => plateTextBox.Text = v); // for UI models that are not POCOs

While the operator types, AK3710 gives Incomplete (not Invalid), so a UI can show a live preview; result.Tokens carries spans and states for highlighting, result.AvailableFields the keys still possible.

Concepts

  • Schema set. Several schemas in one set. Each schema's first declared key is its selector: the input must start with it. The caller can also select a schema explicitly. A built schema set is immutable and thread-safe.
  • Keys. Case-insensitive prefixes such as AK, SUM, HTTP, matched by longest match. Prefix conflicts are reported when the schema is built, not when an operator types.
  • Keyless fields. Recognized by pattern (any value type, plus Validate(...) checks), for example a car plate without a key. An input that fits more than one pattern is an ambiguity diagnostic, never a guess.
  • Value types. Digits (fixed length, range or greedy), Integer, Decimal, Money, Text, Regex, Enum / lookup, and custom types through a delegate.
  • Money. Digits only are minor units (SUM10000 = 100.00); with . or , they are major units (SUM100.50). The currency suffix is optional (E = EUR, configurable).
  • Separator. Free text ends at # or at the end of input; ## is a literal #. The separator is configurable.
  • Cardinality. A field is Single or Many; it can be Required and have a default value.
  • Tolerant parsing. Bad input never throws. The result holds the commands parsed so far and diagnostics with positions and stable codes. Each token is Complete, Incomplete (still being typed) or Invalid, so a UI can show a live preview while the operator types.
  • Binding. Typed field handles (result.Get(field)), result.Bind<T>() / BindTo(obj) with [Comandus("AK")] overrides, and callbacks (result.Apply(field, v => ...)).

Roadmap

  • 0.1.0: parser, value types, diagnostics, binding, examples.
  • Next: completion API (GetCompletions(input, caret)), schemas from JSON, schemas from attributes and a source generator, serializing a result back to a canonical string.
  • 1.0.0: after the completion API, when the public API is stable.

Examples in the repository

Each example runs without arguments on built-in sample inputs (valid, incomplete and invalid), or parses its arguments: dotnet run --project examples/<Name> -- <input>.

Example Shows
CivilLiabilityPolicy Lithuanian civil liability policy: personal code with checksum, car plate
PolicyWithAmount Policy type lookup, keyless personal code, plate and risks, money with currency suffixes
ExportSinks HTTP sink, body ending at the next key, Excel sink, report e-mails, turned into jobs
Invoice Invoice lines (Many), VAT lookup, due date as a custom value type
MultipleSchemas Several schemas in one set, selection by the first key, explicit selection
Binding Typed handles, Bind<T> / BindTo with [Comandus], Apply callbacks, indexer
CustomValueType Custom<T> matchers (dates, composite values), Regex<T>
ManyFields Many, Required, Default, Duplicate diagnostics
Repl Interactive loop: tokens, diagnostics with carets, hints, Lithuanian messages (--demo to run samples)
BlazorLiveForm Blazor WebAssembly page that fills a policy form live while the string is typed

Versioning

Semantic Versioning 2.0.0. While the version is 0.x, a minor release may break the API; from 1.0.0, breaking changes come only with a new major version.

License

MIT © vdasus. Use it freely; keep the copyright notice. The software comes without warranty.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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 was computed.  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.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.

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
0.1.0 0 11/27/2026