togglit-cli
v1.0.3
Published
ToggLit CLI – JSON config fallback and version management
Maintainers
Readme
ToggLit CLI
A command-line interface for managing your configuration using ToggLit — the JSON Config-as-a-Service platform.
🛑 Note: CLI access is restricted to premium users. Free-tier users will need to upgrade to use CLI features.
Installation
You can run it directly with npx:
npx togglit-cli login --api-key YOUR_API_KEYOr install globally:
npm install -g togglit-cliyarn global add togglit-clipnpm add -g togglit-cliQuick Start
togglit login --api-key YOUR_API_KEY
togglit init --project YOUR_PROJECT_ID --env production
togglit pullAPI Reference
login
Authenticate and store your API key for future CLI operations.
Parameters
| Parameter | Type | Required | Description |
| ----------- | -------- | -------- | -------------------------------------------- |
| --api-key | string | ✅ | Your Togglit API key |
| --global | flag | ❌ | Save credentials globally (default: project) |
Example
# Login with project-specific credentials
togglit login --api-key tk_live_xxxxxxx
# Login with global credentials
togglit login --api-key tk_live_xxxxxxx --globalinit
Initialize local project configuration and create a .togglit.json file.
Parameters
| Parameter | Type | Required | Description |
| ----------- | -------- | -------- | ----------------------------------------- |
| --project | string | ✅ | Your project identifier |
| --env | string | ❌ | Environment name (default: 'development') |
Example
# Initialize with default development environment
togglit init --project togglit-demo
# Initialize with specific environment
togglit init --project togglit-demo --env productionpull
Pull configuration from Togglit and save it locally.
Parameters
| Parameter | Type | Required | Description |
| ------------------ | -------- | -------- | ----------------------------------------------------- |
| --project | string | ❌ | Your project identifier (uses config if not provided) |
| --env | string | ❌ | Environment name (uses config if not provided) |
| --config-version | number | ❌ | Specific configuration version to fetch |
| --output | string | ❌ | Output file path (default: 'config.json') |
Example
# Pull latest configuration
togglit pull
# Pull specific version
togglit pull --config-version 2
# Pull to custom output file
togglit pull --output my-config.json
# Pull with explicit project and environment
togglit pull --project my-project --env productionrollback
Rollback to a previous configuration version.
Parameters
| Parameter | Type | Required | Description |
| ------------------ | -------- | -------- | ----------------------------------------------------- |
| --project | string | ❌ | Your project identifier (uses config if not provided) |
| --env | string | ❌ | Environment name (uses config if not provided) |
| --config-version | number | ✅ | Configuration version to rollback to |
Example
# Rollback to version 2
togglit rollback --config-version 2
# Rollback with explicit project and environment
togglit rollback --project my-project --env production --config-version 1diff
Compare your local config with the latest remote version.
Parameters
| Parameter | Type | Required | Description |
| ----------- | -------- | -------- | ----------------------------------------------------- |
| --project | string | ❌ | Your project identifier (uses config if not provided) |
| --env | string | ❌ | Environment name (uses config if not provided) |
| --file | string | ❌ | Local config file to compare (default: 'config.json') |
Example
# Compare with default config.json
togglit diff
# Compare with custom file
togglit diff --file my-config.json
# Compare with explicit project and environment
togglit diff --project my-project --env productiongenerate-fallback
Generate a fallback config file for offline usage.
Parameters
| Parameter | Type | Required | Description |
| ----------- | -------- | -------- | ----------------------------------------------------- |
| --project | string | ❌ | Your project identifier (uses config if not provided) |
| --env | string | ❌ | Environment name (uses config if not provided) |
Example
# Generate fallback for current project
togglit generate-fallback
# Generate fallback for specific project and environment
togglit generate-fallback --project my-project --env productionversions
List available config versions for your project.
Parameters
| Parameter | Type | Required | Description |
| ----------- | -------- | -------- | ----------------------------------------------------- |
| --project | string | ❌ | Your project identifier (uses config if not provided) |
| --env | string | ❌ | Environment name (uses config if not provided) |
Example
# List versions for current project
togglit versions
# List versions for specific project and environment
togglit versions --project my-project --env productionstatus
View current configuration and validation status.
Example
# View current status
togglit statuslogout
Remove your stored credentials.
Parameters
| Parameter | Type | Required | Description |
| ---------- | ------ | -------- | -------------------------------------------- |
| --global | flag | ❌ | Remove global credentials (default: project) |
Example
# Logout from project
togglit logout
# Logout globally
togglit logout --globalFeatures
- Seamless Configuration Management: Pull, compare, and rollback configurations with simple commands
- Version Control: Track and manage different versions of your configuration
- Fallback Generation: Create offline fallback configurations for resilience
- Global and Project-Specific Authentication: Flexible credential management
- Real-time Comparison: Compare local and remote configurations with diff command
Configuration Priority
The CLI uses the following priority order when resolving configuration:
- CLI flags (
--api-key,--project,--env, etc.) - Local config (
.togglit.jsonin current directory) - Global config (
~/.togglit/config.json)
Usage Examples
Basic Workflow
# 1. Login with your API key
togglit login --api-key tk_live_xxxxxxx
# 2. Initialize your project
togglit init --project my-app --env production
# 3. Pull the latest configuration
togglit pull
# 4. Check status
togglit statusVersion Management
# List available versions
togglit versions
# Pull specific version
togglit pull --config-version 2
# Compare current config with remote
togglit diff
# Rollback to previous version
togglit rollback --config-version 1Environment-Specific Operations
# Development environment
togglit init --project my-app --env development
togglit pull
# Production environment
togglit init --project my-app --env production
togglit pull --output prod-config.jsonFallback Configuration
# Generate fallback configuration
togglit generate-fallback
# This creates a fallback config file that can be used
# when the Togglit service is unavailableConfiguration File Structure
The .togglit.json file stores your project configuration:
{
"project": "your-project-id",
"env": "production",
"apiKey": "your-api-key"
}Error Handling
The CLI includes comprehensive error handling:
- Authentication errors: Clear messages when API keys are invalid
- Network errors: Graceful handling of connectivity issues
- Configuration errors: Validation of project and environment parameters
- File system errors: Proper error messages for file operations
Environment Configuration
The CLI connects to your Togglit instance. Make sure you have:
- A valid API key (premium users only)
- Proper network connectivity to Togglit servers
- Appropriate file system permissions for config files
License
MIT
Support
- 📘 Documentation: https://togglit.dev/docs
- 🎯 Pricing: https://togglit.dev/pricing
- 💬 Support: Contact our support team for CLI-related issues
Made with ❤️ by the Togglit team
