summaryrefslogtreecommitdiff
path: root/src/cmds/comp/workspace_alias.rs
blob: 5efabfa6749cf84cd8415b84f00fee5dfad94ff0 (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
use cli_utils::string_vec;

use crate::systems::comp::context::CompletionContext;

pub fn comp(ctx: CompletionContext) -> Option<Vec<String>> {
    if ctx.all_words.contains(&"--insert".to_string()) {
        if ctx.all_words.len() > 7 {
            return None;
        }
    } else if ctx.all_words.len() > 5 {
        return None;
    }

    if ctx.current_word.starts_with('-') {
        return Some(string_vec![
            "-i", "--insert", "-Q", "--query", "-e", "--erase", "--to",
        ]);
    }

    if ctx.previous_word == "--to" {
        return Some(vec![]);
    }

    None
}