Magentrix CLI - Command Reference
Overview
This document provides complete technical reference for all Magentrix CLI commands, their parameters, usage patterns, and examples.
Command Syntax Conventions
magentrix <command> [options] [arguments]
Notation Used:
<required> - Required parameter[optional] - Optional parameter| - Choice between options... - Can be repeated
Global Options
These options work with any command:
| Option | Description |
|---|
--help | Display help for the command |
--version | Display CLI version number |
Examples:
magentrix --help
magentrix pull --help
magentrix --version
Command Overview
Core Commands (Alphabetical)
| Command | Purpose | Common Use Case |
|---|
autopublish | Watch files and auto-upload changes | Real-time development |
config | Manage CLI settings | Configure logging, view settings |
create | Create new files with templates | Start new controllers, pages |
publish | Upload local changes to server | Deploy completed work |
pull | Download files from server | Sync with server state |
setup | Configure API credentials | Initial configuration |
status | Check sync state | Review changes before publish |
Detailed Command Reference
autopublish
Purpose: Watch local files for changes and automatically upload them to the Magentrix server when saved.
Syntax:
magentrix autopublish
Parameters: None
Behavior:
- Starts file watcher on the
src/ directory - Monitors for file changes (create, modify, delete)
- Automatically uploads changed files to server
- Compiles code on server
- Displays compilation results in real-time
- Continues until stopped with Ctrl+C
When to Use:
- During active development requiring immediate feedback
- Testing changes iteratively
- Rapid prototyping
- Learning Magentrix development
When Not to Use:
- Deploying multiple related changes (use
publish instead) - Working with slow internet connection
- Making structural changes across many files
Example Session:
$ magentrix autopublish
🔄 Auto-publish mode started
Watching for file changes... (Press Ctrl+C to stop)
[14:32:15] Changed: src/Controllers/HomeController.ctrl
✓ Uploaded
✓ Compiled successfully
[14:33:22] Changed: src/Pages/Dashboard.aspx
✓ Uploaded
✓ Compiled successfully
[14:34:10] Changed: src/Classes/EmailHelper.ac
✓ Uploaded
✗ Compilation error: Line 42: Missing semicolon
^C
Auto-publish stopped
Performance Note:
- Each file is uploaded individually (slower for many files)
- Server compiles after each upload
- Best for single-file changes
- For bulk changes, use
publish instead
⚠ Important: Changes are uploaded immediately when files are saved. There is no undo except through server rollback.
config
Purpose: Manage CLI configuration settings interactively.
Syntax:
magentrix config
Parameters: None
Interactive Menu:
? What would you like to do?
❯ Log File Settings
View All Settings
Cancel
Options:
1. Log File Settings
Enable or disable detailed operation logs:
? Enable operation logs?
❯ Yes - Save detailed logs for debugging
No - Disable logging
Log Behavior:
- Enabled: Saves detailed logs to
.magentrix/logs/ - Disabled: Only console output, no file logs
- Automatically keeps only 10 most recent logs per operation type
Log File Location:
.magentrix/logs/
├── pull-2024-12-11T10-30-45.log
├── publish-2024-12-11T11-15-22.log
└── autopublish-2024-12-11T14-00-00.log
2. View All Settings
Display current configuration:
Current Configuration:
Instance URL: https://yourcompany.magentrix.com
API Key: *****...***45a3 (masked)
Logs Enabled: Yes
Project Path: /Users/yourname/magentrix-project
Last Pull: 2024-12-11 10:30:45
Last Publish: 2024-12-11 11:15:22
When to Use:
- Enable logs when troubleshooting issues
- Verify current settings
- Check which instance you're connected to
- Disable logs for production deployments
Example:
$ magentrix config
? What would you like to do? Log File Settings
? Enable operation logs? Yes
✓ Logging enabled
Logs will be saved to: .magentrix/logs/
create
Purpose: Create new Magentrix files with proper templates locally and on the server.
Syntax:
Interactive mode:
magentrix create
Non-interactive mode:
magentrix create [options]
Interactive Mode:
The wizard guides you through file creation:
Step 1: Choose Entity Type
? What would you like to create?
❯ ActiveClass (Controller, Class, or Trigger)
ActivePage (Page or Template)
Step 2a: For ActiveClass - Select Type
? Select class type:
❯ Controller
Utility Class
Trigger
Step 2b: For ActivePage - Select Type
? Select page type:
❯ Page
Template
Step 3: Enter Name
? Enter the name: UserManagement
Step 4: Enter Description (Optional)
? Enter description (optional): Manages user accounts
Step 5: For Triggers - Select Entity
? Search for entity: contact
? Select target entity:
❯ Contact (ID: 5001)
Contact Request (ID: 5023)
Contact Group (ID: 5045)
Result:
✓ Creating UserManagementController.ctrl...
✓ File created locally: src/Controllers/UserManagementController.ctrl
✓ File created on server
✓ Template applied
✓ Ready for development!
Non-Interactive Mode Options:
| Option | Description | Required For | Example Value |
|---|
--type <type> | Entity type | All | class, page, template |
--class-type <classType> | Class subtype | Classes only | controller, utility, trigger |
--name <name> | File name | All | UserController |
--description <description> | Optional description | None | "User management" |
--entity-id <entityId> | Target entity ID | Triggers only | 5001 |
Non-Interactive Examples:
Create a controller:
magentrix create --type class --class-type controller --name UserController --description "Handles user operations"
Create a utility class:
magentrix create --type class --class-type utility --name EmailHelper --description "Email utility functions"
Create a trigger:
magentrix create --type class --class-type trigger --entity-id 5001 --name AccountTrigger --description "Account trigger logic"
Create a page:
magentrix create --type page --name Dashboard --description "Main dashboard page"
Create a template:
magentrix create --type template --name EmailTemplate --description "Email notification template"
File Templates:
The CLI creates files with proper boilerplate code:
Controller Template:
public class UserController : BaseController
{
public ActionResult Index()
{
return View();
}
}
Utility Class Template:
public class EmailHelper
{
// Add your utility methods here
}
Trigger Template:
public class AccountTrigger : ActiveTrigger<Account>
{
// Add trigger logic
}
Page Template:
<h1>Dashboard</h1>
<p>Page content goes here</p>
💡 Tip: Mix interactive and non-interactive modes. Provide partial flags and the CLI will prompt for missing information.
publish
Purpose: Upload all local changes to the Magentrix server and compile them.
Syntax:
magentrix publish
Parameters: None
Behavior:
- Scan Phase: Scans local
src/ directory for changes - Analysis Phase: Compares with server state
- Confirmation Phase: Shows changes and asks for confirmation
- Upload Phase: Uploads changed files in parallel
- Compilation Phase: Server compiles uploaded code
- Report Phase: Displays results
Example Session:
$ magentrix publish
📤 Analyzing changes...
Changes to be published:
Created (2):
+ src/Controllers/ReportController.ctrl
+ src/Pages/Reports.aspx
Modified (3):
~ src/Controllers/HomeController.ctrl
~ src/Classes/EmailHelper.ac
~ src/Contents/Assets/css/main.css
Deleted (1):
- src/Pages/OldDashboard.aspx
? Proceed with publish? (Y/n) Y
📤 Publishing changes...
✓ Uploading ReportController.ctrl...
✓ Uploading Reports.aspx...
✓ Uploading HomeController.ctrl...
✓ Uploading EmailHelper.ac...
✓ Uploading main.css...
✓ Deleting OldDashboard.aspx...
✓ Compiling code on server...
✓ All changes published successfully!
Created: 2 files
Updated: 3 files
Deleted: 1 file
Completed in 5.2 seconds
Performance Characteristics:
| Project Size | Scan Time | Upload Time (per file) | Total Time |
|---|
| Small (< 100 files) | < 1 second | 0.5 - 1 second | 2-5 seconds |
| Medium (100-1000 files) | 1-2 seconds | 0.5 - 1 second | 5-15 seconds |
| Large (1000-20000 files) | < 2 seconds | 0.5 - 1 second | 10-30 seconds |
💡 Performance Note: The CLI uses optimized algorithms. Even with 20,000+ files, initial scanning completes in under 2 seconds.
Change Detection:
The CLI tracks changes using:
- File modification timestamps
- Content hashing (SHA-256)
- Server state comparison
Handles:
- New files (created locally)
- Modified files (changed locally)
- Deleted files (removed locally)
- Binary files (images, etc.)
- Text files (code, CSS, etc.)
Best Practices:
- Always run
magentrix status before publish - Review the change list carefully
- Test locally before publishing
- Commit to version control before publishing
- Publish at logical completion points
When to Use:
- Completed feature development
- End of work session
- Before switching tasks
- Deploying tested changes
When Not to Use:
- During active development (use
autopublish) - Before testing changes
- With uncommitted version control changes
⚠ Important: Publishing overwrites server files. Always run status first to review changes.
pull
Purpose: Download all files from the Magentrix server to your local machine.
Syntax:
magentrix pull
Parameters: None
Behavior:
- Connect: Connects to Magentrix server
- Fetch Metadata: Retrieves list of all files
- Conflict Detection: Compares with local state
- Download: Downloads files in batches
- Organize: Saves files to proper directories
- Update Cache: Updates local state tracking
Example Session (First Time):
$ magentrix pull
📥 Pulling from Magentrix...
Fetching file list...
✓ Found 125 files
Downloading files:
Controllers... ████████████████ 15/15
Classes... ████████████████ 8/8
Triggers... ████████████████ 5/5
Pages... ████████████████ 12/12
Templates... ████████████████ 3/3
Assets... ████████████████ 82/82
✓ All files downloaded successfully!
Summary:
Controllers: 15
Classes: 8
Triggers: 5
Pages: 12
Templates: 3
Assets: 82
Total: 125 files
Completed in 8.3 seconds
Example Session (With Conflicts):
$ magentrix pull
📥 Pulling from Magentrix...
⚠ Conflicts detected! (3 files)
The following files have changed both locally and on the server:
~ src/Controllers/HomeController.ctrl
~ src/Classes/EmailHelper.ac
~ src/Pages/Dashboard.aspx
? How would you like to resolve conflicts?
❯ Overwrite Local - Replace local files with server versions
Skip Conflicts - Keep local files, ignore server changes
Manual Review - Review each conflict individually
Conflict Resolution Options:
Option 1: Overwrite Local
- Replaces your local files with server versions
- You lose local changes
- Use when server version is correct
Option 2: Skip Conflicts
- Keeps your local files unchanged
- Ignores server changes
- Use when local version is correct
Option 3: Manual Review
- Reviews each file individually
- Asks for resolution per file
- Allows selective overwriting
Manual Review Example:
File: src/Controllers/HomeController.ctrl
? Resolve this conflict:
❯ Use Server Version
Keep Local Version
Show Diff
[If "Show Diff" selected]
Local (modified 2024-12-11 10:00):
Line 45: return View("Home");
Server (modified 2024-12-11 11:30):
Line 45: return View("Dashboard");
? Resolve this conflict:
❯ Use Server Version
Keep Local Version
First-Time Prompts:
The first time you run pull on a project with many files:
📋 Log File Settings
Magentrix CLI can save detailed operation logs for debugging.
? Would you like to save operation logs to files? (Y/n)
This is a one-time setup. Your choice is saved globally.
When to Use:
- Start of workday (get latest changes)
- Before making major changes (avoid conflicts)
- After teammate publishes changes
- When server files have been modified in IDE
File Organization:
Files are downloaded to:
src/
├── Classes/ ← Utility classes
├── Controllers/ ← Controllers
├── Triggers/ ← Database triggers
├── Pages/ ← ASPX pages
├── Templates/ ← ASPX templates
└── Contents/Assets/ ← Static assets
Progress Tracking:
The command shows separate progress for:
- Code entities (Controllers, Classes, Triggers, Pages, Templates)
- Static assets (CSS, JS, images, etc.)
💡 Best Practice: Always pull before starting work to avoid conflicts.
setup
Purpose: Configure API credentials and connection settings for the Magentrix CLI.
Syntax:
Interactive mode:
magentrix setup
Non-interactive mode:
magentrix setup --api-key <key> --instance-url <url>
Interactive Mode:
$ magentrix setup
Magentrix CLI Setup
───────────────────────────────────────
? Enter your Magentrix API key: [hidden]
? Enter your Magentrix instance URL: https://yourcompany.magentrix.com
✓ Testing connection...
✓ Connection successful!
✓ Credentials saved securely
✓ VS Code file associations configured
Setup complete! Run 'magentrix pull' to download your files.
Non-Interactive Mode:
For automation or CI/CD:
magentrix setup --api-key YOUR_API_KEY --instance-url https://yourcompany.magentrix.com
Options:
| Option | Description | Required | Format |
|---|
--api-key <apiKey> | Magentrix API key | Yes | Alphanumeric string |
--instance-url <instanceUrl> | Magentrix instance URL | Yes | Full URL with https:// |
What Setup Does:
- Validates Credentials: Tests connection to Magentrix
- Saves Securely: Stores credentials in system config directory
- Creates Project Config: Initializes
.magentrix/ directory - Configures Editor: Sets up VS Code file associations (if detected)
- Links Project: Associates current directory with credentials
Configuration Storage:
Global Config Location:
- Mac/Linux:
~/.config/magentrix/ - Windows:
%APPDATA%/magentrix/
Contains:
- API credentials (namespaced by project folder hash)
- Global preferences
- Multiple instance credentials
Project Config Location:
.magentrix/ in project directory
Contains:
- Project-specific cache
- File mappings
- Sync state
Multiple Instance Support:
You can manage multiple Magentrix instances simultaneously:
# Production instance
mkdir ~/magentrix-production
cd ~/magentrix-production
magentrix setup
# Enter production credentials
# Development instance
mkdir ~/magentrix-development
cd ~/magentrix-development
magentrix setup
# Enter development credentials
Each folder maintains independent credentials automatically.
Security:
- API keys are stored securely in system config directories
- Keys are masked in output (*****...***45a3)
- Keys are never logged or displayed in full
- Folder-based namespacing prevents credential conflicts
When to Use:
- Initial CLI installation
- Changing API credentials
- Switching to different Magentrix instance
- After moving/renaming project folder
- Setting up new development machine
Reconfiguration:
To change credentials, simply run setup again. It will overwrite existing configuration.
⚠ Important: Moving or renaming the project folder requires running setup again due to folder hash-based credential storage.
status
Purpose: Compare local files with server state to identify changes, conflicts, and sync status.
Syntax:
magentrix status
Parameters: None
Behavior:
- Scan Local Files: Scans
src/ directory - Fetch Server State: Retrieves server file metadata
- Compare: Identifies differences
- Report: Displays categorized changes
Does NOT:
- Make any changes to files
- Upload anything to server
- Download anything from server
- Modify local state
Example Output (In Sync):
$ magentrix status
📊 Status Report
────────────────────────────────────
✓ All files in sync
✓ No conflicts detected
✓ No unpublished changes
Last Pull: 2024-12-11 10:30:45
Last Publish: 2024-12-11 11:15:22
Example Output (With Changes):
$ magentrix status
📊 Status Report
────────────────────────────────────
Unpublished Local Changes (5):
Created (2):
+ src/Controllers/ReportController.ctrl
+ src/Pages/Reports.aspx
Modified (2):
~ src/Controllers/HomeController.ctrl
~ src/Classes/EmailHelper.ac
Deleted (1):
- src/Pages/OldDashboard.aspx
Server Changes Not in Local (3):
Modified (2):
~ src/Controllers/UserController.ctrl (server newer)
~ src/Pages/Profile.aspx (server newer)
Created (1):
+ src/Classes/NewHelper.ac (exists on server only)
⚠ Conflicts Detected (1):
⚠ src/Controllers/HomeController.ctrl
Both local and server have changes
Local modified: 2024-12-11 10:15:30
Server modified: 2024-12-11 11:00:45
Recommendations:
1. Run 'magentrix pull' to get server changes
2. Resolve conflicts manually
3. Run 'magentrix publish' to upload your changes
Status Categories:
Unpublished Local Changes:
- Files created locally but not on server
- Files modified locally since last publish
- Files deleted locally but still on server
Server Changes Not in Local:
- Files created on server (via IDE or other user)
- Files modified on server since last pull
- Files deleted on server but still local
Conflicts:
- Files changed both locally and on server
- Requires manual resolution
Status Symbols:
| Symbol | Meaning |
|---|
+ | Created (new file) |
~ | Modified (changed file) |
- | Deleted (removed file) |
⚠ | Conflict (changed both places) |
✓ | In sync (no changes) |
When to Use:
- Before running
publish (preview changes) - After running
pull (verify sync) - To check for conflicts before working
- To verify current workspace state
- Before committing to version control
Workflow Example:
# Check status before starting work
magentrix status
# Make changes to files
# ...
# Check what changed
magentrix status
# Verify changes before publishing
magentrix publish
💡 Best Practice: Make status part of your workflow. Run it before publish to avoid surprises.
File Type Reference
Magentrix File Types
Understanding file types helps you use the appropriate commands and organize your code:
| File Type | Extension | Purpose | Created By | Documentation |
|---|
| Controller | .ctrl | Handle HTTP requests, routing, application logic | create --type class --class-type controller | Working with Controllers |
| Class | .ac | Reusable utility code, helpers, business logic | create --type class --class-type utility | Working with Classes |
| Trigger | .trigger | Database event handlers (before/after insert/update/delete) | create --type class --class-type trigger | Working with Triggers |
| Page | .aspx | User-facing web pages with markup and code | create --type page | Working with Pages |
| Template | .aspx | Reusable page layouts and components | create --type template | Working with Templates |
| Asset | Various | Static files: CSS, JavaScript, images, fonts | Manual placement | Managing Static Assets |
File Extensions and Languages
| Extension | Language | Syntax Highlighting | Editor Config |
|---|
.ctrl | C# | C# mode | Configured automatically |
.ac | C# | C# mode | Configured automatically |
.trigger | C# | C# mode | Configured automatically |
.aspx | ASP.NET | HTML mode | Configured automatically |
.css | CSS | CSS mode | Standard |
.js | JavaScript | JavaScript mode | Standard |
.png, .jpg, etc. | Binary | N/A | Standard |
Command Comparison
When to Use Which Command
| Scenario | Recommended Command | Alternative |
|---|
| Start of day | pull | - |
| Making changes | Edit files + autopublish | Edit files + publish |
| Create new file | create | Manual file creation |
| Check changes | status | - |
| Deploy changes | publish | autopublish (for real-time) |
| Get server updates | pull | - |
| Initial setup | setup | - |
| Change settings | config | - |
| Real-time development | autopublish | Repeated publish |
Development Workflow Commands
Daily Development Cycle:
magentrix pull # Start: Get latest
magentrix status # Verify: Check state
# ... make changes ...
magentrix status # Review: Check changes
magentrix publish # Deploy: Upload changes
Real-Time Development:
magentrix pull # Get latest
magentrix autopublish # Start watching
# ... edit and save files automatically uploaded ...
# Ctrl+C to stop
Feature Development:
magentrix pull # Sync first
magentrix create # Create files
# ... develop feature ...
magentrix status # Review changes
magentrix publish # Deploy feature
Advanced Usage
Non-Interactive Automation
All commands support non-interactive operation for CI/CD:
# Setup
magentrix setup --api-key ${MAGENTRIX_API_KEY} --instance-url ${MAGENTRIX_URL}
# Pull
magentrix pull
# Create file
magentrix create --type class --class-type controller --name AutoController
# Publish
magentrix publish
Environment Variables
Store credentials securely:
export MAGENTRIX_API_KEY="your-api-key"
export MAGENTRIX_URL="https://yourcompany.magentrix.com"
magentrix setup --api-key $MAGENTRIX_API_KEY --instance-url $MAGENTRIX_URL
Scripting Examples
Daily sync script:
#!/bin/bash
cd ~/magentrix-project
magentrix pull
magentrix status
Auto-deploy script:
#!/bin/bash
cd ~/magentrix-project
magentrix status
echo "Deploying changes..."
magentrix publish
Error Messages and Solutions
Common Error Messages
Authentication Error:
✗ Authentication failed
Invalid API key or insufficient permissions
Solution: Run magentrix setup with correct credentials
Connection Error:
✗ Cannot connect to instance
Network error or invalid URL
Solution: Check instance URL and internet connection
File Conflict:
⚠ Conflicts detected
Files changed both locally and on server
Solution: Run magentrix pull and resolve conflicts
Compilation Error:
✗ Compilation failed: Line 42: Missing semicolon
Solution: Fix syntax errors in code and republish
Permission Error:
✗ Permission denied
User does not have access to create files
Solution: Contact administrator for proper permissions
Video Tutorial
[Video Placeholder: Magentrix CLI Command Reference]
This video demonstrates:
- Using each command with examples
- Understanding command output
- Common command combinations
- Troubleshooting command errors
Next Steps
Now that you understand all available commands:
Learn Development Workflows: See practical usage patterns
Review Platform Documentation: Understand Magentrix development concepts
Quick Reference Card
╔══════════════════════════════════════════════════════════════╗
║ MAGENTRIX CLI QUICK REFERENCE ║
╠══════════════════════════════════════════════════════════════╣
║ setup Configure credentials ║
║ pull Download from server ║
║ status Check sync state ║
║ publish Upload to server ║
║ create Create new file ║
║ autopublish Auto-sync mode ║
║ config Manage settings ║
║ --help Show help ║
║ --version Show version ║
╠══════════════════════════════════════════════════════════════╣
║ DAILY WORKFLOW: ║
║ magentrix pull → Get latest ║
║ magentrix status → Check state ║
║ [edit files] → Make changes ║
║ magentrix publish → Deploy ║
╚══════════════════════════════════════════════════════════════╝