diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-14 22:12:30 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-14 22:40:12 +0800 |
| commit | 72f80ea51f25256d0c463c2f3dc3d8670cfc4634 (patch) | |
| tree | b200a3ab1a4c718034458863570a064b52bafdcd /src/bin | |
| parent | 54b5567d6f1b1adaa6ada6a26faba0c5c492b7f3 (diff) | |
Add shell completions for new jvn CLI
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/jvn_comp.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/bin/jvn_comp.rs b/src/bin/jvn_comp.rs new file mode 100644 index 0000000..d00916c --- /dev/null +++ b/src/bin/jvn_comp.rs @@ -0,0 +1,54 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +struct CompletionContext { + /// The full command line + #[arg(short = 'f', long)] + command_line: String, + + /// Cursor position + #[arg(short = 'C', long)] + cursor_position: usize, + + /// Current word + #[arg(short = 'w', long)] + current_word: String, + + /// Previous word + #[arg(short = 'p', long)] + previous_word: String, + + /// Command name + #[arg(short = 'c', long)] + command_name: String, + + /// Word index + #[arg(short = 'i', long)] + word_index: usize, + + /// All words + #[arg(short = 'a', long, num_args = 1..)] + all_words: Vec<String>, +} + +fn main() { + let args = match CompletionContext::try_parse() { + Ok(args) => args, + Err(_) => std::process::exit(1), + }; + match comp(args) { + Some(suggestions) => { + suggestions + .iter() + .for_each(|suggest| println!("{}", suggest)); + } + None => { + println!("_file_"); + } + } +} + +fn comp(_args: CompletionContext) -> Option<Vec<String>> { + None +} |
