summaryrefslogtreecommitdiff
path: root/Meta/ShellCompletions/zsh/_serenity
blob: d2916a3f1b70cd90d5e074b9c1afeff4bb608a67 (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
64
#compdef serenity serenity.sh

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

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

    local targets
    targets=(
        'x86_64:Target x86_64 (default)'
        'aarch64:Target aarch64'
        '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|copy-src|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