summaryrefslogtreecommitdiff
path: root/src/systems/comp/context.rs
blob: 8d0adc232f91cd2bb32e4ad4f8c9f2fa7a762fe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use clap::{Parser, ValueEnum};

#[derive(ValueEnum, Debug, Clone, Copy)]
pub enum ShellFlag {
    Zsh,
    Bash,
    Fish,
    Powershell,
}

#[derive(Parser, Debug, Clone)]
#[command(author, version, about, long_about = None)]
pub struct CompletionContext {
    /// The full command line
    #[arg(short = 'f', long)]
    pub command_line: String,

    /// Cursor position
    #[arg(short = 'C', long)]
    pub cursor_position: usize,

    /// Current word
    #[arg(short = 'w', long)]
    pub current_word: String,

    /// Previous word
    #[arg(short = 'p', long)]
    pub previous_word: String,

    /// Command name
    #[arg(short = 'c', long)]
    pub command_name: String,

    /// Word index
    #[arg(short = 'i', long)]
    pub word_index: usize,

    /// All words
    #[arg(short = 'a', long, num_args = 1..)]
    pub all_words: Vec<String>,

    /// Flag to indicate completion context
    #[arg(short = 'F', long, value_enum)]
    pub shell_flag: ShellFlag,
}