Crates.io | send-sms |
lib.rs | send-sms |
version | 0.1.0 |
created_at | 2025-08-24 18:43:31.045934+00 |
updated_at | 2025-08-24 18:43:31.045934+00 |
description | Command-line interface for sending SMS via FreeMobile API |
homepage | https://github.com/davlgd/send-sms |
repository | https://github.com/davlgd/send-sms |
max_upload_size | |
id | 1808674 |
size | 85,657 |
Modern command-line interface for sending SMS via FreeMobile API, using the freemobile-api
library.
This crate provides a comprehensive and intuitive CLI tool for SMS sending. It builds upon the freemobile-api
crate for all API operations and focuses on command-line user experience.
From the parent workspace:
cargo build --release
cargo install --path .
send-sms [OPTIONS]
Options:
-u, --user <USER_ID> FreeMobile user ID (8 digits)
-p, --pass <API_KEY> FreeMobile API key
-m, --message <TEXT> Message to send
-f, --file <PATH> Read message from file
-v, --verbose Verbose output
-h, --help Print help
-V, --version Print version
# Direct message
send-sms -m "Hello from Rust!"
# From a file
send-sms -f message.txt
# From stdin (automatic detection)
echo "Hello World" | send-sms
send-sms < message.txt
# Interactive mode (default)
send-sms
# Verbose mode for debugging
send-sms -m "Test message" -v
The CLI supports multiple configuration methods (in order of priority):
-u
and -p
FREEMOBILE_USER
and FREEMOBILE_PASS
export FREEMOBILE_USER="12345678"
export FREEMOBILE_PASS="your-api-key"
FREEMOBILE_USER=12345678
FREEMOBILE_PASS=your-api-key
When credentials are not provided via CLI arguments or environment variables, the CLI will prompt you interactively:
send-sms -m "Hello world"
# FreeMobile User ID: [you type your 8-digit user ID]
# FreeMobile API Key: [you type your API key, hidden, no confirmation needed]
This makes the CLI user-friendly for first-time users or when testing.
config
: CLI configuration management with validationinput
: Management of different input sources (file, stdin, interactive)main
: Main entry point with operation orchestrationfreemobile-api
: API library (local crate)clap
: CLI argument parsing with validationinquire
: Interactive user interfacetokio
: Async runtime for performancedotenv
: .env file supportThe CLI provides clear error messages for all use cases:
FREEMOBILE_USER
and FREEMOBILE_PASS
freemobile-api
libraryAll error messages include action suggestions to resolve the problem.
#!/bin/bash
# Deployment notification script
if deploy_app; then
send-sms -m "✅ Deployment successful at $(date)"
else
send-sms -m "❌ Deployment failed at $(date)"
fi
# High CPU alert
cpu_usage=$(top -l 1 | grep "CPU usage" | awk '{print $3}' | sed 's/%//')
if (( $(echo "$cpu_usage > 90" | bc -l) )); then
send-sms -m "⚠️ Critical CPU usage: ${cpu_usage}%"
fi
# Build notification
make build && \
send-sms -m "✅ Build successful for commit $(git rev-parse --short HEAD)" || \
send-sms -m "❌ Build failed for commit $(git rev-parse --short HEAD)"
# Unit tests
cargo test -p send-sms-cli
# Tests with detailed output
cargo test -p send-sms-cli -- --nocapture
# Test specific module
cargo test -p send-sms-cli config::tests
Use verbose mode (-v
) to see execution details:
send-sms -v -m "Test message"
# Shows:
# 🚀 Starting send-sms v0.1.0
# 📱 User ID: 1234****
# 📄 Message preview: ...
# 📤 Sending SMS...
# ✅ SMS sent successfully!
For advanced debugging (shows original message when emoji sanitization occurs):
DEBUG=1 send-sms -v -m "Hello 😀 world!"
# Shows:
# 🐛 DEBUG - Original message: Hello 😀 world!
# 🐛 DEBUG - Sanitized message (what will be sent):
# 📄 Message preview: Hello [] world!