From 828470137cb4e806c31a26fa741d5d67c64f98c2 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 28 Oct 2026 22:31:18 +0100 Subject: v0.2.4: fix command UX, completion wrapping and auth prompt cancellation --- src/client/ui.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/client/ui.rs') diff --git a/src/client/ui.rs b/src/client/ui.rs index 036c36a..6fc2f62 100644 --- a/src/client/ui.rs +++ b/src/client/ui.rs @@ -102,6 +102,33 @@ pub fn help_lines() -> Vec { lines } +/// Wrap a completion list to `width` columns, one space between names. +pub fn completion_lines(commands: &[&str], width: usize) -> Vec { + let mut lines = vec!["Possible completions:".to_string()]; + let mut current = String::new(); + + for command in commands { + let needed = if current.is_empty() { + command.len() + } else { + current.len() + 1 + command.len() + }; + if !current.is_empty() && needed > width { + lines.push(current.clone()); + current.clear(); + } + if !current.is_empty() { + current.push(' '); + } + current.push_str(command); + } + + if !current.is_empty() { + lines.push(current); + } + lines +} + /// Add a command to the history, skipping blanks and consecutive duplicates. pub fn record_history(history: &mut Vec, line: &str) { let line = line.trim(); -- cgit v1.2.3