Skip to content

luizrodd/crud-mediator-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

crudcli

npm version npm downloads license

crudcli is a lightweight Node.js CLI tool that helps you scaffold C# Command and CommandHandler classes following the MediatR pattern.
It’s designed to speed up development by generating boilerplate code with consistent namespaces based on your folder structure.


πŸš€ Installation

Install globally with npm:

npm install -g crudcli

Or run it instantly with npx (no global install required):

npx crudcli@latest --help

πŸ›  Usage
crudcli <EntityName> [ReturnType] --startup <FolderName>


<EntityName> β†’ The name of your entity (e.g. Client, Order).

[ReturnType] β†’ The return type of the command (default: Guid).

--startup <FolderName> β†’ The root folder from which the namespace will be generated (inclusive).

πŸ‘‰ Files are created in the current directory where you execute the command.

πŸ“‚ Example

Suppose you are inside:

/home/user/MyApp/src/Application/Clients/Commands

Run:

crudcli Client Guid --startup src


This will generate:

CreateClientCommand.cs
CreateClientCommandHandler.cs

πŸ“ Generated Files

CreateClientCommand.cs

using MediatR;

namespace Src.Application.Clients.Commands
{
    public record CreateClientCommand(
        // TODO: add Client properties
    ) : IRequest<Guid>;
}


CreateClientCommandHandler.cs

using MediatR;

namespace Src.Application.Clients.Commands
{
    public class CreateClientCommandHandler : IRequestHandler<CreateClientCommand, Guid>
    {
        public CreateClientCommandHandler()
        {
        }

        public async Task<Guid> Handle(CreateClientCommand request, CancellationToken cancellationToken)
        {
            // TODO: implement Client creation logic
            return Guid.NewGuid();
        }
    }
}

πŸ”§ Development

Clone the repo and link it locally:

git clone https://github.com/<your-username>/crudcli.git
cd crudcli
npm install
npm link


Now you can run the CLI directly:

crudcli Order Guid --startup Application

πŸ“– Notes

The namespace is automatically derived from your folder structure starting at the folder provided in --startup.

Files are created in the current path.

Requires Node.js v18+.

About

A simple Node.js CLI that scaffolds C# MediatR Command and CommandHandler classes. It automatically generates boilerplate code with consistent namespaces based on your folder structure, making it easier and faster to implement clean, maintainable CQRS patterns in .NET applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors