⚙️ Config Command
FLX CLI-এর configuration setup এবং management।
🎯 Overview
flx config
command ব্যবহার করে আপনি FLX CLI-এর বিভিন্ন configuration option setup এবং manage করতে পারবেন।
📋 Basic Usage
# Show current configuration
flx config
# Set state management to GetX
flx config --state getx
# Set state management to BLoC
flx config --state bloc
# Show help
flx config --help
⚙️ Configuration Options
State Management
# GetX state management (default)
flx config --state getx
# BLoC state management
flx config --state bloc
# Provider state management (coming soon)
flx config --state provider
# Riverpod state management (coming soon)
flx config --state riverpod
Default Packages
# Enable/disable common packages
flx config --http true
flx config --dio false
flx config --shared-preferences true
flx config --hive false
# Database options
flx config --sqflite true
flx config --floor false
flx config --drift false
Code Generation
# Enable Freezed for models
flx config --freezed true
# Enable JSON annotation
flx config --json-annotation true
# Enable code generation
flx config --build-runner true
Testing
# Enable test generation
flx config --generate-tests true
# Enable mock generation
flx config --mockito true
# Test framework
flx config --test-framework flutter-test
📁 Configuration File
FLX CLI configuration stored in .flxrc.json
:
{
"stateManagement": "getx",
"packages": {
"http": true,
"dio": false,
"shared_preferences": true,
"hive": false,
"sqflite": false,
"floor": false,
"drift": false
},
"codeGeneration": {
"freezed": false,
"jsonAnnotation": true,
"buildRunner": false
},
"testing": {
"generateTests": false,
"mockito": false,
"testFramework": "flutter_test"
},
"naming": {
"useCamelCase": true,
"usePrefix": false,
"prefix": ""
},
"folders": {
"features": "features",
"domain": "domain",
"data": "data",
"presentation": "presentation"
}
}
🛠️ Advanced Configuration
Project Structure
# Custom folder names
flx config --features-folder modules
flx config --domain-folder business
flx config --data-folder repositories
flx config --presentation-folder ui
# Use custom prefixes
flx config --use-prefix true
flx config --prefix App
Code Style
# Naming conventions
flx config --use-camel-case true
flx config --file-naming snake_case
# Import organization
flx config --auto-organize-imports true
flx config --relative-imports false
Templates
# Custom templates directory
flx config --templates-dir ./templates
# Template engine
flx config --template-engine mustache
# Custom variables
flx config --set-variable AUTHOR "Your Name"
flx config --set-variable COMPANY "Your Company"
📊 Show Configuration
View Current Config
# Show all configuration
flx config
# Show specific section
flx config --show packages
flx config --show state-management
flx config --show testing
Example Output
$ flx config
FLX CLI Configuration:
======================
State Management: getx
Code Generation:
- Freezed: disabled
- JSON Annotation: enabled
- Build Runner: disabled
Packages:
- HTTP: enabled
- Dio: disabled
- Shared Preferences: enabled
- Hive: disabled
- SQLite: disabled
Testing:
- Generate Tests: disabled
- Mockito: disabled
- Framework: flutter_test
Naming:
- Camel Case: enabled
- Use Prefix: disabled
- Prefix: (none)
Folders:
- Features: features
- Domain: domain
- Data: data
- Presentation: presentation
Config file: /path/to/project/.flxrc.json
🔄 Reset Configuration
# Reset to defaults
flx config --reset
# Reset specific section
flx config --reset packages
flx config --reset state-management
# Confirm reset
flx config --reset --force
🌍 Global vs Local Configuration
Global Configuration
# Set global config (applies to all projects)
flx config --global --state getx
# Show global config
flx config --global
# Global config location: ~/.flx/config.json
Local Configuration
# Set local config (current project only)
flx config --state bloc
# Show local config
flx config --local
# Local config location: ./.flxrc.json
Priority Order
- Local configuration (
.flxrc.json
) - Global configuration (
~/.flx/config.json
) - Default configuration
🎯 Configuration Examples
GetX Project Setup
# Setup for GetX project
flx config --state getx
flx config --http true
flx config --shared-preferences true
flx config --json-annotation true
flx config --generate-tests true
BLoC Project Setup
# Setup for BLoC project
flx config --state bloc
flx config --dio true
flx config --freezed true
flx config --build-runner true
flx config --mockito true
Enterprise Project Setup
# Setup for large enterprise project
flx config --state bloc
flx config --freezed true
flx config --json-annotation true
flx config --build-runner true
flx config --floor true
flx config --mockito true
flx config --generate-tests true
flx config --use-prefix true
flx config --prefix "Enterprise"
🔍 Validation
Config Validation
FLX CLI automatically validates configuration:
# Valid configuration
flx config --state getx
✓ Configuration updated successfully
# Invalid configuration
flx config --state invalid-state
✗ Error: Invalid state management option 'invalid-state'
Valid options: getx, bloc, provider, riverpod
# Conflicting options
flx config --http true --dio true
⚠ Warning: Both HTTP and Dio enabled. Dio will be used.
Compatibility Checks
# Check Flutter compatibility
flx config --check-flutter
# Check Dart SDK compatibility
flx config --check-dart
# Check dependencies compatibility
flx config --check-dependencies
📝 Environment Variables
# Use environment variables
export FLX_STATE_MANAGEMENT=getx
export FLX_GENERATE_TESTS=true
export FLX_USE_FREEZED=false
# Environment variables override config file
flx gen feature auth # Uses env vars
🔧 Configuration Schema
JSON Schema Validation
{
"$schema": "https://flx.dev/schema/config.json",
"type": "object",
"properties": {
"stateManagement": {
"type": "string",
"enum": ["getx", "bloc", "provider", "riverpod"]
},
"packages": {
"type": "object",
"properties": {
"http": {"type": "boolean"},
"dio": {"type": "boolean"},
"shared_preferences": {"type": "boolean"}
}
}
}
}
⚡ Quick Setup Commands
Initialize New Project
# Quick setup for new project
flx config init
# Interactive setup
flx config init --interactive
# Setup with template
flx config init --template enterprise
Import Configuration
# Import from another project
flx config import ../other-project/.flxrc.json
# Import from URL
flx config import https://example.com/flx-config.json
# Import specific sections
flx config import config.json --only packages,testing
Export Configuration
# Export current config
flx config export config.json
# Export for sharing
flx config export --template
# Export to different formats
flx config export config.yaml --format yaml
🐛 Troubleshooting
Common Issues
# Config file not found
$ flx config
Error: No configuration file found
Solution: Run 'flx config init' or 'flx config --state getx'
# Invalid JSON format
$ flx config
Error: Invalid JSON in .flxrc.json at line 5
Solution: Check JSON syntax or run 'flx config --reset'
# Permission denied
$ flx config --global
Error: Permission denied writing to ~/.flx/config.json
Solution: Run with proper permissions or use --local
Debug Mode
# Enable debug output
flx config --debug --state getx
# Verbose output
flx config --verbose
# Dry run (show what would change)
flx config --dry-run --state bloc
✅ Best Practices
- Version Control: Add
.flxrc.json
to version control - Team Consistency: Use same config across team
- Environment Specific: Use different configs for dev/prod
- Regular Updates: Keep config updated with project needs
- Documentation: Document custom configurations
- Validation: Regularly validate config with
--check
Configuration ঠিকভাবে setup করলে: FLX CLI আপনার project requirements অনুযায়ী perfect code generate করবে! ⚙️