feat: complete Rust port of claude-statusline
Port the entire 2236-line bash statusline script to Rust. Implements all 25 sections, 3-phase layout engine (render, priority drop, flex/justify), file-based caching with flock, 9-level terminal width detection, trend sparklines, and deep-merge JSON config. Release binary: 864K with LTO. Render time: <1ms warm. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
60
src/input.rs
Normal file
60
src/input.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct InputData {
|
||||
pub model: Option<ModelInfo>,
|
||||
pub cost: Option<CostInfo>,
|
||||
pub context_window: Option<ContextWindow>,
|
||||
pub workspace: Option<Workspace>,
|
||||
pub version: Option<String>,
|
||||
pub output_style: Option<OutputStyle>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct ModelInfo {
|
||||
pub id: Option<String>,
|
||||
pub display_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct CostInfo {
|
||||
pub total_cost_usd: Option<f64>,
|
||||
pub total_duration_ms: Option<u64>,
|
||||
pub total_lines_added: Option<u64>,
|
||||
pub total_lines_removed: Option<u64>,
|
||||
pub total_tool_uses: Option<u64>,
|
||||
pub last_tool_name: Option<String>,
|
||||
pub total_turns: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct ContextWindow {
|
||||
pub used_percentage: Option<f64>,
|
||||
pub total_input_tokens: Option<u64>,
|
||||
pub total_output_tokens: Option<u64>,
|
||||
pub context_window_size: Option<u64>,
|
||||
pub current_usage: Option<CurrentUsage>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct CurrentUsage {
|
||||
pub cache_read_input_tokens: Option<u64>,
|
||||
pub cache_creation_input_tokens: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct Workspace {
|
||||
pub project_dir: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct OutputStyle {
|
||||
pub name: Option<String>,
|
||||
}
|
||||
Reference in New Issue
Block a user