A Go implementation for command-line interfaces with Node.js compatibility
β οΈ BETA SOFTWARE - NOT READY FOR PRODUCTION USEThis project is currently in active development and is NOT READY FOR PRODUCTION USE.
- π§ Features are incomplete and under active development
- π APIs may change without notice
- π Expect bugs and stability issues
- π Go DLL integration is not fully functional on Windows
Please do not use this in production projects. This is for development and testing purposes only.
This project provides a Go implementation of the command-line interfaces that can be used both as a standalone Go library and as a Node.js addon. The implementation maintains 100% API compatibility with commander.js while leveraging Go's performance benefits.
- Full API compatibility with commander.js
- High-performance Go implementation
- Node.js addon support for use in JavaScript projects
- No external dependencies
- Comprehensive test suite
- Detailed documentation
π§ Core Go Implementation: Complete but needs integration testing
π§ CGO Integration: Implemented but DLL loading issues on Windows
π§ JavaScript Wrapper: Functional with fallback to JS implementation
π§ Testing: Basic functionality verified, integration tests needed
Current Issues:
- Windows DLL loading not working properly
- Go functions not accessible from Node.js addon
- Performance benchmarks not yet validated
- API compatibility not fully tested
β οΈ WARNING: Do not install for production use!
This package is in beta development and should only be used for testing and development purposes.
# DO NOT USE IN PRODUCTION
go get github.com/rohitsoni-dev/gocommander# DO NOT USE IN PRODUCTION
npm install gocommanderRequirements for building from source:
- Visual Studio with C++ development tools (Windows)
- Go 1.25.3 or higher
- Node.js 24 or higher
- npm 11.3.0 or higher
Note: The Go DLL integration is currently not working on Windows.
const { Command, hello, version } = require("gocommander");
// Test Go backend connectivity
console.log("Go backend:", hello());
console.log("Go version:", version());
const program = new Command();
program
.version("1.0.0")
.description("My awesome CLI application powered by Go")
.action(() => {
console.log("Hello from Go backend!");
});
program.parse(process.argv);The JavaScript interface now directly uses the Go implementation for all operations:
const { Command, program, addon } = require("gocommander");
// Create commands that are backed by Go
const app = new Command('myapp');
app
.description('Powered by Go backend')
.option('-v, --verbose', 'Verbose output')
.command('serve', 'Start server')
.action((args, options) => {
// This action is processed through the Go backend
console.log('Server starting with Go performance!');
});
// All parsing is handled by Go
app.parse(process.argv);The project consists of three main components:
- Go Implementation: The core logic written in Go for performance (
src/go/gommander.go) - CGO Exports: C-compatible exports for interfacing with other languages
- Node.js Addon: A native Node.js addon that bridges JavaScript and Go (
src/addon.cc)
- Go 1.25.3 or higher
- Node.js 24 or higher
- npm 11.3.0 or higher
- Visual Studio with C++ development tools (Windows)
- GCC or Clang (macOS/Linux)
- pnpm 10.18.3
- Clone the repository
- Install dependencies:
pnpm install - Build the Go library:
go build -buildmode=c-archive -o src/gommander.a src/go/gommander.go - Build the Node.js addon:
pnpm run build
See the examples directory for usage examples.
A CLI tool for generating project boilerplates:
# List available templates
node examples/boilerplate-generator.js list
# Generate a new Node.js Express project
node examples/boilerplate-generator.js generate node-express my-api
# Generate a new React app with a custom name
node examples/boilerplate-generator.js generate react-app my-app --name "My React Application"This example demonstrates advanced features like:
- Multiple template support
- Dynamic file generation with placeholder replacement
- Nested directory creation
- Comprehensive error handling
A CLI tool for managing todo lists:
# Add a new todo (note: options must come before arguments)
node examples/todo-manager.js add --priority=high --tags=shopping,urgent "Buy groceries"
# List incomplete todos
node examples/todo-manager.js list
# List all todos including completed ones
node examples/todo-manager.js list --all
# Filter by priority
node examples/todo-manager.js list --priority=high
# Filter by tag
node examples/todo-manager.js list --tag=shopping
# Mark a todo as complete
node examples/todo-manager.js complete 1
# Delete a todo
node examples/todo-manager.js delete 2
# Clear completed todos
node examples/todo-manager.js clearThis example demonstrates features like:
- Persistent data storage in JSON format
- Priority levels and tagging system
- Filtering and sorting capabilities
- Data validation and error handling
- Proper handling of command-line argument ordering
β οΈ Note: Tests currently run with JavaScript fallback due to Go DLL loading issues.
# Run Go tests (when Go integration is fixed)
go test ./src/go/...
# Run JavaScript tests (currently working)
pnpm test
# Run example (uses JavaScript implementation)
node example.js# Test basic functionality (JavaScript fallback)
node test/test.js
# Test advanced features (JavaScript fallback)
node test/advanced-test.js
# Run the example CLI (JavaScript implementation)
node example.js serve ./public --port 8080 --watchCurrent Test Status:
- β JavaScript implementation tests pass
β οΈ Go integration tests fail due to DLL loading issues- π§ Performance tests not yet implemented
β οΈ Note: Performance benchmarks are theoretical and not yet validated in the current beta implementation.
The Go implementation is designed to provide significant performance improvements over the pure JavaScript version while maintaining API compatibility.
This project is in active development. If you're interested in contributing:
- Please understand this is beta software
- Check the issues for known problems
- Test thoroughly before submitting PRs
- Follow the existing code style
THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. This is beta software under active development. Use at your own risk. The authors are not responsible for any issues, data loss, or problems that may arise from using this software.
MIT