| Crates.io | mudra-cli |
| lib.rs | mudra-cli |
| version | 0.1.0 |
| created_at | 2025-08-19 08:11:42.406037+00 |
| updated_at | 2025-08-19 08:11:42.406037+00 |
| description | A robust, high-performance currency converter with caching and CLI interface |
| homepage | https://github.com/AshishBagdane/mudra |
| repository | https://github.com/AshishBagdane/mudra |
| max_upload_size | |
| id | 1801560 |
| size | 205,004 |
A robust, high-performance currency converter built in Rust with real-time and historical exchange rates, intelligent caching, and a beautiful CLI interface.
Mudra (เคฎเฅเคฆเฅเคฐเคพ) - Sanskrit/Hindi word meaning "currency" or "money"
# Install from crates.io
cargo install mudra-cli
# Or build from source
git clone https://github.com/AshishBagdane/mudra.git
cd mudra
cargo build --release
# Or download pre-built binaries from GitHub releases
# https://github.com/AshishBagdane/mudra/releases
Note: The package name is
mudra-clibut the binary is calledmudra
export EXCHANGE_API_KEY=your_api_key_here
# Convert 100 USD to EUR
mudra convert 100 USD EUR
# Output: 100.00 USD = 85.23 EUR
# Get current exchange rates for USD
mudra rates USD
# Historical conversion
mudra convert 100 USD EUR --date 2024-01-01
# Interactive mode
mudra interactive
# Compare across multiple currencies
mudra compare 100 USD EUR,GBP,JPY,CAD
# Basic conversion
mudra convert <amount> <from> <to>
# With custom precision
mudra convert 100 USD EUR --precision 4
# Historical conversion
mudra convert 100 USD EUR --date 2024-01-01
# Verbose output
mudra convert 100 USD EUR --verbose
# Compact list
mudra list
# Extended format
mudra list --extended
# Filter currencies
mudra list --filter EUR
# All rates for USD
mudra rates USD
# Specific currencies only
mudra rates USD --currencies EUR,GBP,JPY
# Historical rates
mudra rates USD --date 2024-01-01
# Limited results
mudra rates USD --limit 10
# Compare across multiple currencies
mudra compare 100 USD EUR,GBP,JPY,CAD,AUD
# Historical comparison
mudra compare 100 USD EUR,GBP --date 2024-01-01
# View cache statistics
mudra cache stats
# Clear all cached data
mudra cache clear
# Clean up expired entries
mudra cache cleanup
mudra interactive
# Then use commands like:
# > 100 USD EUR
# > convert 50 GBP JPY
# > rates USD
# > list
# > help
# > quit
use currency_converter::{CurrencyConverter, ConversionRequest};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create converter (requires EXCHANGE_API_KEY environment variable)
let converter = CurrencyConverter::from_env()?;
// Convert 100 USD to EUR
let request = ConversionRequest::from_components(100.0, "USD", "EUR")?;
let result = converter.convert(request).await?;
println!("Conversion: {}", result.summary());
println!("Rate: {:.6}", result.exchange_rate);
println!("Result: {}", result.result);
Ok(())
}
use currency_converter::{
CurrencyConverter, ExchangeRateService, CurrencyClient,
Config, CacheConfig, ConversionRequest
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Custom configuration
let config = Config::new()
.with_api_key("your-api-key")
.with_timeout(std::time::Duration::from_secs(10));
// Custom cache configuration
let cache_config = CacheConfig {
max_capacity: 500,
latest_ttl: 600, // 10 minutes
historical_ttl: 7200, // 2 hours
enable_stats: true,
};
// Create client and service
let client = CurrencyClient::with_config(config)?;
let service = ExchangeRateService::with_cache_config(client, cache_config);
let converter = CurrencyConverter::new(service);
// Batch conversion
let requests = vec![
ConversionRequest::from_components(100.0, "USD", "EUR")?,
ConversionRequest::from_components(100.0, "USD", "GBP")?,
ConversionRequest::from_components(100.0, "USD", "JPY")?,
];
let results = converter.convert_batch(requests).await;
for (i, result) in results.iter().enumerate() {
match result {
Ok(conversion) => println!("Conversion {}: {}", i + 1, conversion.summary()),
Err(e) => println!("Error {}: {}", i + 1, e),
}
}
// Check cache performance
let stats = converter.exchange_service.get_cache_stats();
println!("Cache hit rate: {:.1}%", stats.hit_rate);
Ok(())
}
use currency_converter::{ExchangeRateService, api::types::HistoricalConversionRequest};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let service = ExchangeRateService::from_env()?;
// Historical conversion
let request = HistoricalConversionRequest {
amount: 100.0,
from: "USD".to_string(),
to: "EUR".to_string(),
date: "2024-01-01".to_string(),
};
let result = service.convert_historical(request).await?;
println!("Historical rate on 2024-01-01: {:.6}", result.conversion_rate);
// Get historical rates
let rates = service.get_historical_rates("USD", "2024-01-01").await?;
println!("USD rates on {}: {:?}", rates.get_date_string(), rates.conversion_rates);
Ok(())
}
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ CLI โ โ Library โ โ API Client โ
โ (clap-based) โโโโโถโ (type-safe) โโโโโถโ (HTTP client) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Cache โ โ External API โ
โ (in-memory) โ โ (exchangerate- โ
โโโโโโโโโโโโโโโโโโโ โ api.com) โ
โโโโโโโโโโโโโโโโโโโ
// Example: GBP โ JPY via USD
// Step 1: Get USD rates (contains both GBP and JPY)
// Step 2: Calculate cross rate: JPY_rate / GBP_rate
// Step 3: Apply rate to amount
# Unit tests
cargo test
# Integration tests (requires wiremock)
cargo test --test integration_tests
# With coverage (requires cargo-tarpaulin)
cargo tarpaulin --out html
The project includes property-based tests using proptest:
# Run property tests
cargo test property_tests
# Run benchmarks (requires API key for realistic results)
EXCHANGE_API_KEY=your_key cargo run --bin benchmarks
# Memory usage analysis
cargo run --bin benchmarks 2>&1 | grep "bytes"
Typical performance on modern hardware:
git clone https://github.com/AshishBagdane/mudra.git
cd mudra
cargo build
# Check code
cargo check
# Format code
cargo fmt
# Lint code
cargo clippy
# Run tests
cargo test
# Build release
cargo build --release
# Run mudra
./target/release/mudra --help
# Build documentation
cargo doc --open
git checkout -b feature-namecargo testcargo fmtThe converter supports 168+ currencies including:
Use currency_converter list to see all supported currencies.
EXCHANGE_API_KEY: Your API key (required)EXCHANGE_BASE_URL: Custom API base URL (optional)NO_COLOR: Disable colored output (optional)CacheConfig {
max_capacity: 1000, // Maximum cached entries
latest_ttl: 300, // Latest rates TTL (seconds)
historical_ttl: 3600, // Historical rates TTL (seconds)
enable_stats: true, // Enable statistics collection
}
"API key not found"
export EXCHANGE_API_KEY=your_actual_api_key
"Invalid currency code"
currency_converter list for supported currencies"Network timeout"
"Rate limit exceeded"
# Enable verbose logging
RUST_LOG=debug mudra convert 100 USD EUR --verbose
This project is licensed under the MIT License - see the LICENSE file for details.
Made with โค๏ธ and ๐ฆ Rust