ModCLI is a command-line interface tool for the Modular framework that helps you scaffold and generate code for modular applications.
Install the latest version directly using Go:
go install github.com/GoCodeAlone/modular/cmd/modcli@latestAfter installation, the modcli command will be available in your PATH.
git clone https://github.com/GoCodeAlone/modular.git
cd modular/cmd/modcli
go installDownload the latest release for your platform from the releases page.
ModCLI provides several commands to help you build modular applications:
Create a new module for your modular application with the following command:
modcli generate module --name MyModule --output ./modulesThis will create a new module in the specified output directory with the given name. The command will prompt you for module features including:
- Configuration support
- Tenant awareness
- Module dependencies
- Startup and shutdown logic
- Service provisioning
- Test generation
For configuration-enabled modules, you can define configuration fields, types, and validation requirements.
Create a new configuration structure with:
modcli generate config --name AppConfig --output ./configThis command helps you define configuration structures with proper validation, default values, and serialization formats (YAML, JSON, TOML, etc.).
# Generate a basic module with minimal features
modcli generate module --name Basic --output .# Generate a module with all features enabled
modcli generate module --name FullFeatured --output .When prompted, select all features (configuration, tenant awareness, etc.)
# Generate a module that focuses on configuration
modcli generate module --name ConfigOnly --output .When prompted, select configuration support but disable other features.
The generate module command creates the following files:
module.go- Main module implementationconfig.go- Configuration structure (if enabled)config-sample.yaml/json/toml- Sample configuration files (if enabled)module_test.go- Test file with test cases for your modulemock_test.go- Mock implementations for testingREADME.md- Documentation for your modulego.mod- Go module file
The generate config command creates:
config.go- Configuration structure with validationconfig-sample.yaml/json/toml- Sample configuration files
ModCLI is built using the cobra command framework and generates code using Go templates.
main.go- Entry pointcmd/- Command implementationsroot.go- Root commandgenerate_module.go- Module generation logicgenerate_config.go- Config generation logic
go test ./... -vContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.