Skip to content

Commit 78b93e6

Browse files
hanbu97claude
andcommitted
fix: resolve clippy too-many-arguments lint in render_top_frame
Extract render parameters into TopFrameState struct to satisfy clippy::too_many_arguments (10/7 limit). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fa228bf commit 78b93e6

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tokenusage"
3-
version = "1.3.0"
3+
version = "1.3.1"
44
edition = "2024"
55
description = "Fast Rust CLI/TUI/GUI token usage tracker for Codex, Claude Code, and Antigravity usage."
66
license = "MIT"

src/pipeline.rs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,15 +1261,17 @@ pub(crate) async fn run_top(args: TopArgs) -> Result<()> {
12611261
// Render
12621262
render_top_frame(
12631263
&mut session,
1264-
&sessions_display,
1265-
&rates,
1266-
&total_display,
1267-
total_rate,
1268-
sort_key,
1269-
&tz,
1270-
live_runtime.is_none(),
1271-
show_all,
1272-
merge_projects,
1264+
&TopFrameState {
1265+
sessions: &sessions_display,
1266+
rates: &rates,
1267+
total: &total_display,
1268+
total_rate,
1269+
sort_key,
1270+
tz: &tz,
1271+
loading: live_runtime.is_none(),
1272+
show_all,
1273+
merge_projects,
1274+
},
12731275
)?;
12741276

12751277
// Handle input (non-blocking)
@@ -1306,18 +1308,33 @@ pub(crate) async fn run_top(args: TopArgs) -> Result<()> {
13061308
Ok(())
13071309
}
13081310

1309-
fn render_top_frame(
1310-
session: &mut BlocksLiveSession,
1311-
sessions: &[TopSession],
1312-
rates: &HashMap<String, f64>,
1313-
total: &TokenCounts,
1311+
struct TopFrameState<'a> {
1312+
sessions: &'a [TopSession],
1313+
rates: &'a HashMap<String, f64>,
1314+
total: &'a TokenCounts,
13141315
total_rate: f64,
13151316
sort_key: TopSortKey,
1316-
tz: &TimeZoneMode,
1317+
tz: &'a TimeZoneMode,
13171318
loading: bool,
13181319
show_all: bool,
13191320
merge_projects: bool,
1321+
}
1322+
1323+
fn render_top_frame(
1324+
session: &mut BlocksLiveSession,
1325+
state: &TopFrameState<'_>,
13201326
) -> Result<()> {
1327+
let TopFrameState {
1328+
sessions,
1329+
rates,
1330+
total,
1331+
total_rate,
1332+
sort_key,
1333+
tz,
1334+
loading,
1335+
show_all,
1336+
merge_projects,
1337+
} = state;
13211338
session.terminal.draw(|frame| {
13221339
let area = frame.area();
13231340

@@ -1332,8 +1349,8 @@ fn render_top_frame(
13321349
.split(area);
13331350

13341351
// Header
1335-
let status = if loading { " [loading...]" } else { "" };
1336-
let mode = if show_all { "all" } else { "active" };
1352+
let status = if *loading { " [loading...]" } else { "" };
1353+
let mode = if *show_all { "all" } else { "active" };
13371354
let header_text = format!(
13381355
" tokenusage top — {} sessions ({mode}) | ${:.2} | {:.0} tok/min{}",
13391356
sessions.len(),
@@ -1470,7 +1487,7 @@ fn render_top_frame(
14701487
if i > 0 {
14711488
footer_spans.push(Span::raw(" "));
14721489
}
1473-
let style = if *sk == sort_key {
1490+
let style = if *sk == *sort_key {
14741491
Style::default()
14751492
.fg(TuiColor::Cyan)
14761493
.add_modifier(Modifier::BOLD)
@@ -1479,12 +1496,12 @@ fn render_top_frame(
14791496
};
14801497
footer_spans.push(Span::styled(format!("[{key}]{label}"), style));
14811498
}
1482-
let all_label = if show_all { "active" } else { "all" };
1499+
let all_label = if *show_all { "active" } else { "all" };
14831500
footer_spans.push(Span::styled(
14841501
format!(" [a]{all_label}"),
14851502
Style::default().fg(TuiColor::DarkGray),
14861503
));
1487-
let merge_style = if merge_projects {
1504+
let merge_style = if *merge_projects {
14881505
Style::default()
14891506
.fg(TuiColor::Cyan)
14901507
.add_modifier(Modifier::BOLD)

0 commit comments

Comments
 (0)