From 965196972fa27237b6cb97209c915381a95a5bef Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Tue, 17 Mar 2026 15:23:43 +0100 Subject: builtin to determine what completion would do --- src/run/builtin.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/run/builtin.rs') diff --git a/src/run/builtin.rs b/src/run/builtin.rs index 141357f..f0cb999 100644 --- a/src/run/builtin.rs +++ b/src/run/builtin.rs @@ -375,6 +375,33 @@ impl Builtin for parse { } } +pub struct completion; +impl Builtin for completion { + fn name(&self) -> &str { + "completion" + } + + fn io( + &self, + session: Arc>, + args: &[BString], + _stdin: &mut dyn Read, + stdout: &mut dyn Write, + ) -> Result { + for arg in args { + let c = crate::completion(session.clone(), &arg); + write!(stdout, "{:?} ", c.kind)?; + stdout.write_all(&c.shared_prefix)?; + for s in c.suggestions { + stdout.write_all(b" ")?; + stdout.write_all(&s.display)?; + } + stdout.write_all(b"\n")?; + } + Ok(()) + } +} + pub struct null; impl Builtin for null { fn name(&self) -> &str { -- cgit v1.2.3