Swap.CLI
0.0.2
dotnet tool install --global Swap.CLI --version 0.0.2
dotnet new tool-manifest
dotnet tool install --local Swap.CLI --version 0.0.2
#tool dotnet:?package=Swap.CLI&version=0.0.2
nuke :add-package Swap.CLI --version 0.0.2
Swap CLI
Generate production-ready ASP.NET Core + HTMX applications with beautiful DaisyUI components.
Swap CLI is a code generator that creates complete, modern web applications using ASP.NET Core MVC, HTMX for interactivity, DaisyUI for UI components, and Entity Framework Core for data access. Generate full CRUD operations with pagination, search, sorting, filtering, and modal-based editing in seconds.
🌟 Why Swap?
- ⚡ Production-Ready Code - Generate complete CRUD with modals, pagination, sorting, filtering, and search
- 🎯 HTMX Simplicity - Modern, interactive web apps without JavaScript frameworks
- � DaisyUI + Tailwind - Beautiful, accessible components out of the box
- 🗄️ Entity Framework Core - Full database integration with migrations support
- 💻 Developer Experience - CLI-driven workflow, no manual boilerplate
- 📦 Proven Patterns - Every pattern extracted from real production applications
🚀 Quick Start
Prerequisites
Before installing Swap CLI, ensure you have:
- .NET 9.0 SDK or later - Download
- Node.js (LTS) - Includes npm for Tailwind CSS compilation
- Windows:
winget install OpenJS.NodeJS.LTSor download from nodejs.org - macOS:
brew install node - Linux: Use your package manager
- Windows:
- libman CLI - Manages client libraries (HTMX, DaisyUI)
dotnet tool install -g Microsoft.Web.LibraryManager.Cli
Verify installations:
dotnet --version # Should be 9.0 or higher
npm --version # Any recent version
libman --version # Any version
Installation
# Install the Swap CLI tool
dotnet tool install --global Swap.CLI --prerelease
# Verify installation
swap --version
Create Your First Project
# Create a new ASP.NET Core + HTMX application
swap new MyApp
cd MyApp
# Apply migrations and run
dotnet ef database update
dotnet run
Visit http://localhost:5000 - Your HTMX-powered application is running! 🎉
Note: The CLI automatically runs npm install, libman restore, and npm run build:css during project creation.
Generate Your First CRUD
# Generate a complete CRUD controller with all features
swap generate controller Product --fields "Name:string Price:decimal InStock:bool:f"
# Short alias
swap g c Product --fields "Name:string Price:decimal InStock:bool:f"
# Update database
dotnet ef migrations add AddProduct
dotnet ef database update
Visit http://localhost:5000/Product - Full CRUD with pagination, search, sorting, and filtering! 🚀
No manual file creation. No boilerplate. Just CLI commands and business logic.
🎯 What You Get
Complete Feature Set
Every generated controller includes:
- ✅ CRUD Operations - Create, Read, Update, Delete via HTMX modals
- ✅ Pagination - Configurable page sizes (10, 25, 50, 100)
- ✅ Real-Time Search - 500ms debounced search across fields
- ✅ Column Sorting - Ascending/descending toggle per field
- ✅ Boolean Filtering - Dropdown filters (All/Yes/No) for bool fields
- ✅ Bulk Operations - Select multiple items and bulk delete
- ✅ Toast Notifications - Success/error messages with DaisyUI alerts
- ✅ Modal Editing - No page reloads, smooth UX
- ✅ Validation - Client and server-side with clear error messages
- ✅ Responsive Design - Works perfectly on mobile and desktop
Generated Stack
- Backend: ASP.NET Core 9.0 MVC
- Frontend: HTMX + DaisyUI + Tailwind CSS
- Database: Entity Framework Core (SQLite, SQL Server, PostgreSQL)
- UI Library: DaisyUI 4.x components
- Styling: Tailwind CSS 3.x utilities
📋 CLI Commands
swap new <name>
Create a new ASP.NET Core + HTMX application with DaisyUI components.
swap new MyApp
Generates:
- Complete ASP.NET Core MVC project structure
- Entity Framework Core with SQLite (configurable)
- DaisyUI + Tailwind CSS configuration
- Sample TodoItem model and CRUD
- Database migrations
- Ready to run immediately
swap generate controller <name> --fields <fields>
Generate a complete CRUD controller with all features.
# Generate Product controller with fields
swap g c Product --fields "Name:string Price:decimal InStock:bool:f"
# With nullable fields
swap g c Customer --fields "Name:string Email:string Notes:string?"
# Control sorting and filtering per field
swap g c Order --fields "OrderNumber:string:ns Total:decimal Date:DateTime Status:bool:f"
Field Flags:
:sortableor:s- Enable sorting (default for all fields):nosortor:ns- Disable sorting:filterableor:f- Enable filtering (bool fields only)
Generates:
- Controller with full CRUD operations
- Model class with validation
- View model for list operations
- Views (Index, _List, _CreateModal, _EditModal, _DetailsModal)
- Automatic DbContext updates
swap generate model <name> --fields <fields>
Generate just a model class (no controller or views).
swap g m Category --fields "Name:string Description:string?"
swap generate resource <name> --fields <fields>
Generate model + controller together (alias for backward compatibility).
swap g r BlogPost --fields "Title:string Content:string PublishedDate:DateTime"
📚 Documentation
- Getting Started - Complete setup guide
- CLI Reference - All commands and options
- Features Guide - Pagination, search, sorting, filtering
- Pattern Library - 30+ proven HTMX patterns
- The Product Vision - Philosophy and approach
🛠️ Development
Prerequisites
- .NET 9.0 SDK or later
- Your favorite IDE (Visual Studio 2022, VS Code, Rider)
Building the CLI from Source
# Clone the repository
git clone https://github.com/jdtoon/swap.git
cd swap
# Build the CLI tool
cd tools/Swap.CLI
dotnet build
# Run tests
cd ../Swap.CLI.Tests
dotnet test
# Install locally for testing
cd ../Swap.CLI
dotnet pack
dotnet tool install --global --add-source ./nupkg Swap.CLI
Project Structure
swap/
├── tools/
│ ├── Swap.CLI/ # CLI tool source code
│ │ ├── Commands/ # Command implementations
│ │ ├── Infrastructure/ # Template engine, helpers
│ │ └── Program.cs # CLI entry point
│ └── Swap.CLI.Tests/ # 136 passing tests
│ ├── Commands/ # Command tests
│ └── Infrastructure/ # Template engine tests
├── templates/ # Code generation templates
│ ├── monolith/ # New project template
│ └── generate/ # CRUD generation templates
│ ├── controller/ # Controller, views, view model
│ └── model/ # Model class
├── docs/ # Documentation
│ ├── THE-PRODUCT.md # Product vision
│ └── PATTERNS-LIBRARY.md # HTMX patterns
├── wiki/ # Docusaurus documentation site
└── README.md # This file
🤝 Contributing
Contributions are welcome! Whether it's bug reports, feature requests, or code contributions.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Ensure all tests pass (
dotnet test) - Commit your changes (
git commit -m 'feat: Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CONTRIBUTING.md for detailed guidelines.
📄 License
Swap CLI is MIT licensed. Use it freely in your projects, commercial or otherwise.
� Project Status
Current Version: 0.1.0-dev (Active Development)
✅ Phase 2C Complete (Current)
- ✅ New Project Generation -
swap newcommand with full ASP.NET Core setup - ✅ Controller Generation -
swap g cwith all CRUD operations - ✅ Model Generation -
swap g mfor entity classes - ✅ Pagination - Configurable page sizes (10, 25, 50, 100)
- ✅ Search - Real-time search with 500ms debounce
- ✅ Sorting - Column sorting with field-level control
- ✅ Filtering - Boolean filters with dropdown UI
- ✅ Modal Editing - Create, Edit, Details modals via HTMX
- ✅ Bulk Delete - Select multiple items and delete
- ✅ Toast Notifications - DaisyUI alerts for success/error
- ✅ DaisyUI Components - Modern, accessible UI library
- ✅ Tailwind CSS - Utility-first styling
- ✅ 136 Passing Tests - Comprehensive test coverage
- ✅ Documentation - Complete wiki with examples
🔄 Phase 2D: Seeders (Next)
- ⏳ Database Seeding - Generate seed data for testing
- ⏳ Faker Integration - Realistic fake data generation
- ⏳ Seeder Commands -
swap g seederCLI command
🎯 Phase 3: Polish & Release
- ⏳ NuGet Package - Publish to NuGet.org
- ⏳ VS Code Extension - Integrated CLI experience
- ⏳ Video Tutorials - Getting started screencasts
- ⏳ Production Release (v1.0.0) - Q1 2026
See the complete roadmap for details.
💬 Community
- Documentation: https://jdtoon.github.io/swap/
- GitHub Issues: https://github.com/jdtoon/swap/issues
- GitHub Discussions: Coming soon
For questions or feedback, open an issue!
🔗 Links
- Documentation: https://jdtoon.github.io/swap/
- GitHub: https://github.com/jdtoon/swap
- Issues: https://github.com/jdtoon/swap/issues
- NuGet (coming soon): https://www.nuget.org/packages/Swap.CLI
Built with ❤️ for the .NET community
Swap CLI - Generate production-ready ASP.NET + HTMX applications in seconds.
| Product | Versions 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. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|