| Crates.io | iron_cli |
| lib.rs | iron_cli |
| version | 0.4.0 |
| created_at | 2025-11-25 13:53:27.209197+00 |
| updated_at | 2025-12-18 09:25:33.828182+00 |
| description | Command-line interface for Iron Cage agent management |
| homepage | |
| repository | https://github.com/.../iron_runtime |
| max_upload_size | |
| id | 1949796 |
| size | 1,127,895 |
Command-line interface for LLM token management using the unilang framework.
[dependencies]
iron_cli = { path = "../iron_cli" }
iron_cli is the authoritative source for operations commands. The Python CLI (iron_cli_py) wraps this binary rather than reimplementing operations logic.
See: ADR-002 for architecture decision.
Domains owned by iron_cli:
| Domain | Commands | Description |
|---|---|---|
| Authentication | login, refresh, logout | JWT token management |
| Tokens | generate, list, get, rotate, revoke, validate, inspect | API token CRUD |
| Usage | show, by_project, by_provider, export | Usage analytics |
| Limits | list, get, create, update, delete | Budget limits CRUD |
| Traces | list, get, export | Request trace inspection |
| Health | health, version | System status |
Wrapper relationship:
iron_cli_py (Python) iron_cli (Rust)
│ │
│ WRAPPER COMMANDS: │ NATIVE IMPLEMENTATION:
│ token.* ─────────────────▶│ Token CRUD
│ usage.* ─────────────────▶│ Usage reporting
│ limits.* ─────────────────▶│ Limits management
│ traces.* ─────────────────▶│ Traces inspection
│ auth.* ───────────────── │ Authentication
│ health ─────────────────▶│ Health/version
│ │
│ NATIVE COMMANDS: │
│ init, config, agent, │
│ secrets (NOT delegated) │
└────────────────────────────┘
# Authentication
iron-token .auth.login username::alice password::secret123
# List tokens
iron-token .tokens.list
# Generate token
iron-token .tokens.generate name::my-token scope::read:tokens ttl::3600
# Revoke token
iron-token .tokens.revoke name::my-token
# Check health
iron-token .health
# Get version
iron-token .version
Current Status: Unilang migration in progress (Phases 1-6 complete)

Visual Guide:
See root readme for detailed architecture explanation.
CLI (unilang) → Adapter (async I/O) → Handler (pure logic) → Formatter (output)
↓ ↓ ↓ ↓
VerifiedCommand Services HashMap validation Table/JSON/YAML
Components:
src/handlers/) - Pure business logic, no I/O, fully testablesrc/adapters/) - Async I/O bridge, calls handlers + services
src/formatting.rs) - Universal output (table/expanded/json/yaml)src/config.rs) - Hierarchical configuration systemUnilang keyword::value format:
iron-token .command.subcommand param1::value1 param2::value2
Examples:
# Login
.auth.login username::user@example.com password::secret
# Refresh tokens
.auth.refresh
# Logout
.auth.logout
# Generate token
.tokens.generate name::api-token scope::read:write:tokens ttl::7200
# List tokens
.tokens.list filter::api
# Get token
.tokens.get name::api-token
# Rotate token
.tokens.rotate name::api-token
# Revoke token
.tokens.revoke name::api-token
# Show usage
.usage.show start_date::2025-01-01 end_date::2025-12-31
# Usage by project
.usage.by_project project_id::my-project
# Usage by provider
.usage.by_provider provider::openai
# Export usage
.usage.export output::usage.csv format::csv
# List limits
.limits.list
# Get limit
.limits.get limit_id::lim_tokens
# Create limit
.limits.create resource_type::tokens limit_value::100000
# Update limit
.limits.update limit_id::lim_tokens limit_value::200000
# Delete limit
.limits.delete limit_id::lim_tokens
# List traces
.traces.list filter::error limit::50
# Get trace
.traces.get trace_id::trace-123
# Export traces
.traces.export output::traces.json format::json
# Health check
.health
# Version
.version
Configuration Hierarchy (highest to lowest priority):
Environment Variables:
IRON_CLI_API_URL=https://api.example.com
IRON_CLI_FORMAT=json
IRON_CLI_USER=alice
IRON_CLI_TOKEN=your-token-here
Example Config:
use iron_cli::config::Config;
// Simple usage
let config = Config::new();
// With CLI args
let mut cli_args = HashMap::new();
cli_args.insert("format".to_string(), "json".to_string());
let config = Config::with_cli_args(cli_args);
// Builder pattern
let config = Config::builder()
.with_cli_args(cli_args)
.with_env()
.with_defaults()
.validate()
.build();
All commands support multiple output formats:
# Table format (default)
iron-token .tokens.list
# Expanded format
iron-token .tokens.list format::expanded
# JSON format
iron-token .tokens.list format::json
# YAML format
iron-token .tokens.list format::yaml
Test Commands:
# Run all tests
cargo test --all-features
# Run specific test suites
cargo test --test handlers
cargo test --test adapters
cargo test --test integration_test
cargo test --test config_test
# Run with strict warnings
RUSTFLAGS="-D warnings" cargo nextest run --all-features
Test Coverage:
Architecture Principles:
Module Structure:
src/
├── handlers/ # Pure business logic (sync, no I/O)
│ ├── auth_handlers.rs
│ ├── token_handlers.rs
│ ├── usage_handlers.rs
│ ├── limits_handlers.rs
│ ├── traces_handlers.rs
│ └── health_handlers.rs
├── adapters/ # Async I/O bridge
│ ├── auth.rs
│ ├── tokens.rs
│ ├── usage.rs
│ ├── limits.rs
│ ├── traces.rs
│ ├── health.rs
│ ├── services.rs # Service trait definitions
│ └── implementations/
│ └── in_memory.rs
├── formatting.rs # Universal formatter
├── config.rs # Configuration system
└── lib.rs # Module exports
tests/
├── handlers.rs # Handler unit tests
├── adapters.rs # Adapter integration tests
├── integration_test.rs # End-to-end tests
├── config_test.rs # Config tests
└── formatting.rs # Formatter tests
Completed Phases (6/10):
Deferred:
Remaining:
Current Metrics:
Responsibilities: Provides command-line access to all Iron Cage token management features using the unilang keyword::value syntax. Implements hexagonal architecture with pure handlers for business logic, async adapters for I/O, and multiple output formatters for terminal display.
In Scope:
Out of Scope:
| File | Responsibility |
|---|---|
| lib.rs | Command-line interface for token management |
| config.rs | Configuration system with hierarchical precedence |
| adapters/ | Adapter layer for unilang CLI |
| bin/ | CLI binary entry points for iron-token and iron commands |
| formatting/ | Universal formatter supporting 4 output formats |
| handlers/ | Pure business logic handlers for CLI commands |
Notes:
MIT