summaryrefslogtreecommitdiff
path: root/Meta/ShellCompletions/zsh/_serenity
blob: 880fd29fb07a4f942708555d6dfea8155317d36c (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#compdef serenity serenity.sh

_serenity() {
    local args
    args=(
        '1:command:->commands'
        '2:target:->targets'
        '*:: :->args'
    )

    local commands
    commands=(
        'build'
        'install'
        'image'
        'run'
        'gdb'
        'test'
        'delete'
        'recreate'
        'rebuild'
        'kaddr2line'
        'addr2line'
        'rebuild-toolchain'
        'rebuild-world'
    )

    local targets
    targets=(
        'i686:Target i686 (default)'
        'x86_64:Target x86_64'
        'lagom:Target host machine'
    )

    _arguments -C -S "$args[@]"

    local command
    command="$line[1]"

    local target
    target="$line[2]"

    case "$state" in
        commands)
            _describe 'command' commands
            ;;
        targets)
            case "$command" in
                install|image|kaddr2line|rebuild-toolchain|rebuild-world)
                    # lagom target is not supported for these, remove from targets
                    targets[$targets[(i)lagom]]=()
                    ;;
            esac
            _describe 'target' targets
            ;;
        args)
            ;;
    esac

    return 0
}

_serenity