Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3,426 Commits

Repository files navigation

TimeWarp.Nuru

NuGet VersionNuGet DownloadsBuild StatusLicenseAsk DeepWiki

Route-based CLI framework for .NET - bringing web-style routing to command-line applications

Nuru means "light" in Swahili - illuminating the path to your commands with clarity and simplicity.

📦 Installation

dotnet add package TimeWarp.Nuru

🚀 Quick Start

TimeWarp.Nuru offers two patterns for defining CLI commands. Start with the Endpoint DSL for structured apps, or Fluent DSL for quick scripts.

Endpoint DSL

Define routes as classes with [NuruRoute] attributes:

usingTimeWarp.Nuru;[NuruRoute("add",Description="Add two numbers together")]publicsealedclassAddCommand:ICommand<Unit>{[Parameter(Order=0)]publicdoubleX{get;set;}[Parameter(Order=1)]publicdoubleY{get;set;}publicsealedclassHandler:ICommandHandler<AddCommand,Unit>{publicValueTask<Unit>Handle(AddCommandcommand,CancellationTokenct){Console.WriteLine($"{command.X} + {command.Y} = {command.X+command.Y}");returndefault;}}}// In your main file:NuruAppapp=NuruApp.CreateBuilder().DiscoverEndpoints().Build();returnawaitapp.RunAsync(args);

Fluent DSL

Define routes inline with a fluent builder API:

usingTimeWarp.Nuru;NuruAppapp=NuruApp.CreateBuilder().Map("add {x:double} {y:double}").WithHandler((doublex,doubley)=>Console.WriteLine($"{x} + {y} = {x+y}")).AsCommand().Done().Build();returnawaitapp.RunAsync(args);
dotnet run -- add 15 25
# Output: 15 + 25 = 40

Full Getting Started Guide

✨ Key Features

FeatureDescriptionLearn More
🎯 Web-Style RoutingFamiliar "deploy {env} --version {tag}" syntaxRouting Guide
📦 Endpoint DSLClass-based commands with DiscoverEndpoints() auto-discoveryArchitecture Choices
🔧 Fluent DSLInline routes with .Map().WithHandler().Done() chainArchitecture Choices
🛡️ Roslyn AnalyzerCatch route errors at compile-timeAnalyzer Docs
⌨️ Shell CompletionTab completion for bash, zsh, PowerShell, fishShell Completion
🤖 MCP ServerAI-assisted development with ClaudeMCP Server Guide
📊 Logging PackageZero-overhead structured loggingLogging Docs
🚀 Native AOTZero warnings, 3.3 MB binaries, instant startupDeployment Guide
🔒 Type-Safe ParametersAutomatic type conversion and validationSupported Types
📖 Auto-HelpGenerate help from route patternsAuto-Help Feature
🎨 Rich TerminalColors, tables, panels, rules via TimeWarp.TerminalTerminal Guide

📚 Documentation

Getting Started

Core Features

Tools & Deployment

Reference

🎯 Two Powerful Use Cases

🆕 Greenfield CLI Applications

Build modern command-line tools from scratch:

myapp/
├── calculator.cs # Single runfile - just 5 lines
└── endpoints/
├── add-command.cs
├── factorial-command.cs
└── ...

Endpoint DSL approach (class-based, organized by file):

// In endpoints/add-command.cs[NuruRoute("add",Description="Add two numbers")]publicsealedclassAddCommand:ICommand<Unit>{[Parameter]publicdoubleX{get;set;}[Parameter]publicdoubleY{get;set;}publicsealedclassHandler:ICommandHandler<AddCommand,Unit>{publicValueTask<Unit>Handle(AddCommandc,CancellationTokenct){Console.WriteLine($"{c.X} + {c.Y} = {c.X+c.Y}");returndefault;}}}

Fluent DSL approach (inline definitions):

NuruApp.CreateBuilder().Map("deploy {env} --version {tag?}").WithHandler((stringenv,string?tag)=>Deploy(env,tag)).AsCommand().Done().Build();

🔄 Progressive Enhancement

Wrap existing CLIs to add auth, logging, or validation:

NuruAppapp=NuruApp.CreateBuilder(args).Map("deploy prod").WithHandler(async()=>{if(!awaitValidateAccess())return1;returnawaitShell.ExecuteAsync("existing-cli","deploy","prod");}).AsCommand().Done().Map("{*args}").WithHandler(async(string[]args)=>awaitShell.ExecuteAsync("existing-cli",args)).AsCommand().Done().Build();

Detailed Use Cases with Examples

🌟 Working Examples

Calculator Samples - Three complete implementations you can run now:

./samples/02-calculator/01-calc-endpoints.cs add 10 20 # Endpoint DSL: structured
./samples/02-calculator/02-calc-fluent.cs factorial 5 # Fluent DSL: inline

AOT Example - Native AOT compilation with source generators

⚡ Performance

ImplementationMemorySpeed (37 tests)Binary Size
Direct (JIT)~4 KB2.49sN/A
Direct (AOT)~4 KB0.30s 🚀3.3 MB
Endpoints (AOT)Moderate0.42s 🚀4.8 MB

Native AOT is 88-93% faster than JITFull Performance Benchmarks

🤖 AI-Powered Development

For AI agents: Load the built-in Nuru Skill for instant access to:

  • Complete DSL syntax and patterns
  • Testing with TestTerminal
  • Route examples and type conversion

💡 Tip: No MCP installation needed - the skill provides all essential patterns.

For MCP Server: Install for Claude Code, Roo Code, or Continue:

dotnet tool install --global TimeWarp.Nuru.Mcp

Get instant help:

  • Validate route patterns before writing code
  • Generate handler code automatically
  • Get syntax examples on demand
  • Real-time error guidance

MCP Server Setup Guide

⌨️ Shell Completion

Enable tab completion for your CLI with one line of code:

NuruAppapp=NuruApp.CreateBuilder(args).Map("deploy {env} --version {tag}").WithHandler((stringenv,stringtag)=>Deploy(env,tag)).AsCommand().Done().Map("status").WithHandler(()=>ShowStatus()).AsQuery().Done().EnableStaticCompletion()// ← Add this.Build();

Generate completion scripts for your shell:

# Bash
./myapp --generate-completion bash >>~/.bashrc
# Zsh
./myapp --generate-completion zsh >>~/.zshrc
# PowerShell
./myapp --generate-completion powershell >>$PROFILE# Fish
./myapp --generate-completion fish >~/.config/fish/completions/myapp.fish

Supports:

  • ✅ Command completion (deploy, status)
  • ✅ Option completion (--version, --force)
  • ✅ Short option aliases (-v, -f)
  • ✅ All 4 major shells (bash, zsh, PowerShell, fish)

See completion-example for a complete working example.

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for details.

For Contributors:

📄 License

This project is licensed under the Unlicense - see the license file for details.


Ready to build powerful CLI applications?

Get Started in 5 MinutesView ExamplesRead the Docs

About

Route-based CLI framework for .NET - Nuru means 'light' in Swahili

Resources

Stars

112 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages