RecordCommander 0.1.0

There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package RecordCommander --version 0.1.0
                    
NuGet\Install-Package RecordCommander -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="RecordCommander" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RecordCommander" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="RecordCommander" />
                    
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 RecordCommander --version 0.1.0
                    
#r "nuget: RecordCommander, 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.
#addin nuget:?package=RecordCommander&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=RecordCommander&version=0.1.0
                    
Install as a Cake Tool

RecordCommander

RecordCommander is a C# library that enables you to create, update, and manage records using a command-line–inspired interface. With a focus on simplicity and flexibility, RecordCommander allows you to register your data types, define unique keys and property mappings, and use both positional and named arguments to seed data or integrate with import/export systems.

Features

  • Command-Based Record Management: Create or update records using single-line commands (e.g., add language nl Dutch).
  • Flexible Configuration: Register classes by specifying unique keys, positional property order, and named property assignments.
  • Data Seeding & Import/Export: Ideal for seeding data, providing sample data for documentation, or integrating with external systems.
  • JSON–Like Parsing: Supports complex property values (including arrays) with JSON–like syntax.
  • No External Dependencies: Uses only the default Microsoft libraries.

Getting Started

Installation

Simply clone the repository and include the source code in your project. Since RecordCommander relies solely on standard .NET libraries, no additional NuGet packages are required.

Configuration

Before running commands, register your record types with the library. For example, suppose you have the following domain classes:

public class MyData
{
    public List<Language> Languages { get; set; } = new List<Language>();
    public List<Country> Countries { get; set; } = new List<Country>();
}

public class Language
{
    public string Key { get; set; }
    public string Name { get; set; }
}

public class Country
{
    public string Code { get; set; }
    public string Name { get; set; }
    public string[] SpokenLanguages { get; set; } = Array.Empty<string>();
}

You would register them as follows:

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using RecordCommander; // Use your namespace

// Register the Language record.
RecordCommandRegistry.Register<MyData, Language>(
    commandName: "language",
    collectionAccessor: ctx => ctx.Languages,
    uniqueKeySelector: x => x.Key,
    positionalPropertySelectors: new Expression<Func<Language, object>>[] { x => x.Name }
);

// Register the Country record.
RecordCommandRegistry.Register<MyData, Country>(
    commandName: "country",
    collectionAccessor: ctx => ctx.Countries,
    uniqueKeySelector: x => x.Code,
    positionalPropertySelectors: new Expression<Func<Country, object>>[] { x => x.Name, x => x.SpokenLanguages }
);

Running Commands

After registration, you can execute commands that create or update records in your data context. For example:

// Create a context instance.
var context = new MyData();

// Run commands to seed or update data.
RecordCommandRegistry.Run(context, "add language nl Dutch");
RecordCommandRegistry.Run(context, "add language fr French");
RecordCommandRegistry.Run(context, "add country be Belgium");
// Update an existing record using named arguments:
RecordCommandRegistry.Run(context, "add country be --SpokenLanguages=['nl','fr']");

Example Output

After executing the commands above, you might see output like:

Languages:
Key: nl, Name: Dutch
Key: fr, Name: French

Countries:
Code: be, Name: Belgium, SpokenLanguages: nl, fr

How It Works

  1. Registration:
    You register each record type with a command name, a lambda to access the target collection from your context, and expressions that define the unique key and positional properties.

  2. Command Parsing:
    The Run method tokenizes the input command. It supports quoted strings, simple escape sequences, and recognizes tokens prefixed with -- as named property assignments.

  3. Record Updating/Creation:
    The library searches for an existing record using the unique key. If found, it updates the record’s properties; otherwise, it creates a new record and adds it to the collection.

  4. Type Conversion:
    Values are converted to the target property types using built-in conversion mechanisms. Array values can be provided in a JSON–like syntax for easy parsing.

Contributing

Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET 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.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on RecordCommander:

Package Downloads
Vidyano

Vidyano is a full featured development platform with the flexibility for creating small to enterprise scale web applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.17.0 2,744 3/4/2025
0.16.0 104 2/28/2025
0.15.0 124 2/25/2025