-
Notifications
You must be signed in to change notification settings - Fork 35
CLI Reference
rUv edited this page Jul 31, 2025
·
1 revision
Complete command-line interface documentation for FACT across all platforms.
- Python CLI
- Rust CLI
- Common Options
- Interactive Mode
- Query Processing
- Cache Management
- Benchmarking
- Configuration
- Output Formats
- Scripting Examples
The Python CLI provides comprehensive access to FACT's financial data analysis capabilities.
# Start interactive mode (default)
python main.py
# Process single query
python main.py --query "What is TechCorp's revenue?"
# Initialize system
python main.py init
# Run demo
python main.py demopython main.py initInitializes the database schema, validates configuration, and prepares the system for use.
python main.py demoRuns example queries to demonstrate FACT capabilities.
python main.py interactive
# or simply
python main.pyStarts the interactive query interface.
Once in interactive mode:
💬 > help # Show available commands
💬 > status # Display system status
💬 > cache stats # Show cache statistics
💬 > cache clear # Clear cache
💬 > tools list # List available tools
💬 > history # Show query history
💬 > export [file] # Export results
💬 > exit # Exit interactive mode
# Basic query
python main.py --query "List all companies"
# With output format
python main.py --query "Get revenue data" --format json
# With cache control
python main.py --query "Analyze trends" --no-cache
# With debug output
python main.py --query "Complex analysis" --debugThe Rust CLI offers high-performance processing with cognitive templates.
# Install from crates.io
cargo install fact-tools
# Or build from source
cd cargo-crate
cargo build --release# Process with template
fact process data.json --template analysis-basic
# List templates
fact templates list
# Cache operations
fact cache stats
# Run benchmarks
fact benchmark
# Initialize configuration
fact init# Basic processing
fact process input.json
# With specific template
fact process data.json --template pattern-detection
# With output file
fact process input.json --output results.json
# Streaming mode
cat data.json | fact process --stream# List available templates
fact templates list
# Show template details
fact templates show analysis-basic
# Search templates
fact templates search "pattern"
# Create custom template
fact templates create my-template --file template.json# Show cache statistics
fact cache stats
# Clear cache
fact cache clear
# Set cache size
fact cache resize 1000
# Export cache
fact cache export cache-dump.json
# Import cache
fact cache import cache-dump.json# Run default benchmark
fact benchmark
# Custom iterations
fact benchmark --iterations 10000
# Specific operations
fact benchmark --operations cache,template
# Output results
fact benchmark --output bench-results.json# Create default config
fact init
# With custom path
fact init --config-path ./my-config.json
# Interactive setup
fact init --interactiveCreate fact.json in your project root:
{
"cache": {
"max_size": 10000,
"ttl_seconds": 3600,
"eviction_policy": "lru"
},
"templates": {
"default": "analysis-basic",
"custom_path": "./templates"
},
"performance": {
"parallel_operations": true,
"max_threads": 8
}
}Options available across both CLIs:
--help, -h # Show help information
--version, -v # Display version
--config, -c <file> # Use custom config file
--verbose # Enable verbose output
--debug # Enable debug output
--quiet, -q # Suppress non-error output# Python
export ANTHROPIC_API_KEY="your-key"
export ARCADE_API_KEY="your-key"
export FACT_DB="custom.db"
export FACT_CACHE_PREFIX="myapp"
export FACT_LOG_LEVEL="DEBUG"
# Rust
export FACT_CONFIG_PATH="/path/to/config.json"
export FACT_CACHE_DIR="/path/to/cache"
export FACT_LOG_LEVEL="debug"
export RUST_LOG="fact=debug"Both CLIs support natural language queries:
# Financial queries
"What is the revenue for Q1 2025?"
"Show me technology sector companies"
"Calculate growth rate for TechCorp"
# Data analysis
"Analyze trends in financial data"
"Compare performance metrics"
"Generate quarterly report"# Python
--query-timeout 30 # Timeout in seconds
--max-results 100 # Limit results
--cache-only # Use cache only
--fresh-data # Skip cache
# Rust
--timeout 30 # Processing timeout
--limit 100 # Result limit
--parallel # Enable parallel processing# Python CLI
python main.py cache stats
python main.py cache clear
python main.py cache export cache.json
python main.py cache import cache.json
# Rust CLI
fact cache stats --detailed
fact cache clear --confirm
fact cache optimize
fact cache warm data.json# Set cache size (Python)
export FACT_CACHE_MAX_SIZE=10000
# Set cache TTL (Python)
export FACT_CACHE_TTL=3600
# Configure Rust cache
fact cache config --max-size 10000 --ttl 3600# Python benchmarks
python -m benchmarking.framework --suite all
python -m benchmarking.framework --suite cache --iterations 1000
# Rust benchmarks
fact benchmark --full
fact benchmark --operations cache,template,process
fact benchmark --compare baseline.json{
"timestamp": "2025-07-31T20:00:00Z",
"operations": {
"cache_hit": {
"ops_per_sec": 40000,
"avg_latency_ms": 0.025
},
"template_process": {
"ops_per_sec": 6667,
"avg_latency_ms": 0.15
}
}
}# Python configuration
.env # Environment variables
config/config.yaml # Application config
config/logging.yaml # Logging config
# Rust configuration
fact.json # Main config
templates/ # Custom templates
cache/ # Cache directory# Python - Update at runtime
python main.py config set cache.max_size 5000
python main.py config get cache.max_size
python main.py config list
# Rust - Config commands
fact config set cache.max_size 5000
fact config get cache.max_size
fact config validate# Python formats
--format json # JSON output
--format csv # CSV output
--format table # Formatted table (default)
--format markdown # Markdown table
--format yaml # YAML output
# Rust formats
--output-format json # JSON output
--output-format csv # CSV output
--output-format pretty # Pretty printed (default)
--output-format binary # Binary format# JSON output
python main.py --query "Get data" --format json | jq .
# CSV for spreadsheets
python main.py --query "Export records" --format csv > data.csv
# Markdown for documentation
fact process data.json --output-format markdown > results.md#!/bin/bash
# fact-daily-report.sh
# Process daily data
echo "Processing daily financial data..."
python main.py --query "Generate daily report" --format json > daily-report.json
# Check cache health
CACHE_STATS=$(python main.py cache stats --format json)
HIT_RATE=$(echo $CACHE_STATS | jq .hit_rate)
if (( $(echo "$HIT_RATE < 0.8" | bc -l) )); then
echo "Warning: Cache hit rate below 80%"
python main.py cache optimize
fi
# Archive results
tar -czf "reports/daily-$(date +%Y%m%d).tar.gz" daily-report.json#!/usr/bin/env python3
# fact_batch_processor.py
import subprocess
import json
from datetime import datetime
queries = [
"Analyze Q1 revenue",
"Calculate growth metrics",
"Generate executive summary"
]
results = {}
for query in queries:
output = subprocess.run(
["python", "main.py", "--query", query, "--format", "json"],
capture_output=True,
text=True
)
results[query] = json.loads(output.stdout)
# Save consolidated report
with open(f"report_{datetime.now():%Y%m%d}.json", "w") as f:
json.dump(results, f, indent=2)// fact_automation.rs
use std::process::Command;
use serde_json::Value;
fn main() {
// Process with fact CLI
let output = Command::new("fact")
.args(&["process", "data.json", "--template", "analysis-basic"])
.output()
.expect("Failed to execute fact");
let result: Value = serde_json::from_slice(&output.stdout)
.expect("Failed to parse output");
println!("Processing complete: {:?}", result);
}# .github/workflows/fact-analysis.yml
name: FACT Analysis
on:
schedule:
- cron: '0 0 * * *' # Daily at midnight
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install FACT
run: |
pip install fact-system
cargo install fact-tools
- name: Run Analysis
run: |
python main.py init
python main.py --query "Daily analysis" --format json > results.json
fact benchmark --output benchmark.json
- name: Upload Results
uses: actions/upload-artifact@v2
with:
name: fact-results
path: |
results.json
benchmark.json# Warm cache before heavy processing
python main.py cache warm --data historical.json
# Use parallel processing in Rust
fact process large-dataset.json --parallel --threads 8
# Batch queries for efficiency
cat queries.txt | python main.py --batch --format json# Enable debug logging
export FACT_LOG_LEVEL=DEBUG
python main.py --debug --query "Complex query"
# Rust debug output
RUST_LOG=fact=debug fact process data.json
# Trace execution
python main.py --trace --query "Slow query" 2> trace.log# Chain operations
python main.py --query "Extract data" | \
fact process --stream --template transform | \
python main.py --query "Analyze results"
# Custom templates
fact process data.json --template ./my-templates/custom.json
# Export for other tools
python main.py --query "Export all" --format csv | \
csvkit --stats > analysis.txtThis CLI reference provides comprehensive documentation for using FACT from the command line across both Python and Rust implementations.