Skip to content

Commit

Permalink
feat(tui): show unique flow count in header
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiapple852 committed Nov 26, 2023
1 parent dda2502 commit 9a3cacb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/frontend/render/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use trippy::dns::{ResolveMethod, Resolver};
use trippy::tracing::{PortDirection, TracerProtocol};

/// Render the title, config, target, clock and keyboard controls.
#[allow(clippy::too_many_lines)]
pub fn render(f: &mut Frame<'_>, app: &TuiApp, rect: Rect) {
let header_block = Block::default()
.title(format!(" Trippy v{} ", clap::crate_version!()))
Expand Down Expand Up @@ -83,6 +84,11 @@ pub fn render(f: &mut Frame<'_>, app: &TuiApp, rect: Rect) {
let source = render_source(app);
let dest = render_destination(app);
let target = format!("{source} -> {dest}");
let plural_flows = if app.tracer_data().flows().len() > 1 {
"flows"
} else {
"flow"
};
let left_line = vec![
Line::from(vec![
Span::styled("Target: ", Style::default().add_modifier(Modifier::BOLD)),
Expand All @@ -98,8 +104,10 @@ pub fn render(f: &mut Frame<'_>, app: &TuiApp, rect: Rect) {
Span::styled("Status: ", Style::default().add_modifier(Modifier::BOLD)),
Span::raw(render_status(app)),
Span::raw(format!(
", discovered {} hops",
app.tracer_data().hops(app.selected_flow).len()
", discovered {} hops and {} unique {}",
app.tracer_data().hops(app.selected_flow).len(),
app.tracer_data().flows().len(),
plural_flows
)),
]),
];
Expand Down

0 comments on commit 9a3cacb

Please sign in to comment.