lean_ctx_cli/cli/completions/
mod.rs1mod engine;
6mod shells;
7pub mod spec;
8mod spec_account;
9mod spec_setup;
10mod spec_team;
11mod spec_tools;
12mod spec_value;
13mod workspace;
14
15pub fn run_completions(args: &[String]) {
17 let shell = args.first().map_or("zsh", String::as_str);
18 let script = match shell {
19 "zsh" => shells::zsh_script(),
20 "bash" => shells::bash_script(),
21 "fish" => shells::fish_script(),
22 other => {
23 eprintln!("Unknown shell: {other} (supported: zsh, bash, fish)");
24 std::process::exit(1);
25 }
26 };
27 print!("{script}");
28}
29
30#[allow(non_snake_case)]
32pub fn run___complete(args: &[String]) {
33 let (shell, words) = match args.iter().position(|a| a == "--") {
34 Some(pos) => {
35 let shell = args.first().map_or("zsh", String::as_str);
36 (shell, &args[pos + 1..])
37 }
38 None => ("zsh", args),
39 };
40
41 let completions = engine::complete(words);
42
43 let output = match shell {
44 "zsh" => shells::format_zsh(&completions),
45 "fish" => shells::format_fish(&completions),
46 _ => shells::format_bash(&completions),
47 };
48 print!("{output}");
49}