File tree 8 files changed +381
-4
lines changed
8 files changed +381
-4
lines changed Original file line number Diff line number Diff line change 16
16
bin /
17
17
.idea /
18
18
dist /
19
+
20
+ .DS_Store
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ archives:
24
24
darwin : mac
25
25
files :
26
26
- LICENSE
27
+ - ' autocomplete/*'
27
28
release :
28
29
github :
29
30
owner : livekit
Original file line number Diff line number Diff line change @@ -18,3 +18,6 @@ check_lfs:
18
18
exit 1; \
19
19
fi \
20
20
}
21
+
22
+ fish_autocomplete : cli
23
+ ./bin/livekit-cli generate-fish-completion -o autocomplete/fish_autocomplete
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # livekit-cli autocomplete for bash
4
+ # original: https://github.com/urfave/cli/blob/main/autocomplete/bash_autocomplete
5
+
6
+ _cli_bash_autocomplete () {
7
+ if [[ " ${COMP_WORDS[0]} " != " source" ]]; then
8
+ local cur opts base
9
+ COMPREPLY=()
10
+ cur=" ${COMP_WORDS[COMP_CWORD]} "
11
+ if [[ " $cur " == " -" * ]]; then
12
+ opts=$( ${COMP_WORDS[@]: 0: $COMP_CWORD } ${cur} --generate-bash-completion )
13
+ else
14
+ opts=$( ${COMP_WORDS[@]: 0: $COMP_CWORD } --generate-bash-completion )
15
+ fi
16
+ COMPREPLY=( $( compgen -W " ${opts} " -- ${cur} ) )
17
+ return 0
18
+ fi
19
+ }
20
+
21
+ complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete livekit-cli
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ # livekit-cli autocomplete for zsh
2
+ # original: https://github.com/urfave/cli/blob/main/autocomplete/zsh_autocomplete
3
+
4
+ _cli_zsh_autocomplete() {
5
+ local -a opts
6
+ local cur
7
+ cur=${words[-1]}
8
+ if [[ "$cur" == "-"* ]]; then
9
+ opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
10
+ else
11
+ opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-bash-completion)}")
12
+ fi
13
+
14
+ if [[ "${opts[1]}" != "" ]]; then
15
+ _describe 'values' opts
16
+ else
17
+ _files
18
+ fi
19
+ }
20
+
21
+ compdef _cli_zsh_autocomplete livekit-cli
Original file line number Diff line number Diff line change @@ -14,14 +14,29 @@ import (
14
14
15
15
func main () {
16
16
app := & cli.App {
17
- Name : "livekit-cli" ,
18
- Usage : "CLI client to LiveKit" ,
17
+ Name : "livekit-cli" ,
18
+ Usage : "CLI client to LiveKit" ,
19
+ Version : livekitcli .Version ,
20
+ EnableBashCompletion : true ,
21
+ Suggest : true ,
19
22
Flags : []cli.Flag {
20
23
& cli.BoolFlag {
21
24
Name : "verbose" ,
22
25
},
23
26
},
24
- Version : livekitcli .Version ,
27
+ Commands : []* cli.Command {
28
+ {
29
+ Name : "generate-fish-completion" ,
30
+ Action : generateFishCompletion ,
31
+ Hidden : true ,
32
+ Flags : []cli.Flag {
33
+ & cli.StringFlag {
34
+ Name : "out" ,
35
+ Aliases : []string {"o" },
36
+ },
37
+ },
38
+ },
39
+ },
25
40
}
26
41
27
42
logger .SetLogger (stdr .New (log .Default ()), "livekit-cli" )
@@ -38,3 +53,21 @@ func main() {
38
53
fmt .Println (err )
39
54
}
40
55
}
56
+
57
+ func generateFishCompletion (c * cli.Context ) error {
58
+ fishScript , err := c .App .ToFishCompletion ()
59
+ if err != nil {
60
+ return err
61
+ }
62
+
63
+ outPath := c .String ("out" )
64
+ if outPath != "" {
65
+ if err := os .WriteFile (outPath , []byte (fishScript ), 0o644 ); err != nil {
66
+ return err
67
+ }
68
+ } else {
69
+ fmt .Println (fishScript )
70
+ }
71
+
72
+ return nil
73
+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ set -o pipefail
8
8
9
9
REPO=" livekit-cli"
10
10
INSTALL_PATH=" /usr/local/bin"
11
+ BASH_COMPLETION_PATH=" /usr/share/bash-completion/completions"
12
+ ZSH_COMPLETION_PATH=" /usr/share/zsh/site-functions"
13
+ FISH_COMPLETION_PATH=" /usr/share/fish/vendor_completions.d"
11
14
12
15
log () { printf " %b\n" " $* " ; }
13
16
abort () {
82
85
log " Installing ${REPO} ${VERSION} "
83
86
log " Downloading from ${ARCHIVE_URL} ..."
84
87
85
- curl -s -L " ${ARCHIVE_URL} " | ${SUDO_PREFIX} tar xzf - -C " ${INSTALL_PATH} " --wildcards --no-anchored " $REPO *"
88
+ TEMP_DIR_PATH=" $( mktemp -d) "
89
+
90
+ curl -s -L " ${ARCHIVE_URL} " | ${SUDO_PREFIX} tar xzf - -C " ${TEMP_DIR_PATH} " --wildcards --no-anchored " $REPO *"
91
+
92
+ mv " ${TEMP_DIR_PATH} /livekit-cli" " ${INSTALL_PATH} /livekit-cli"
93
+
94
+ if [ -d " ${TEMP_DIR_PATH} /autocomplete" ]
95
+ then
96
+ if [ -d " ${BASH_COMPLETION_PATH} " ]
97
+ then
98
+ mv " ${TEMP_DIR_PATH} /autocomplete/bash_autocomplete" " ${BASH_COMPLETION_PATH} /livekit-cli"
99
+ fi
100
+
101
+ if [ -d " ${ZSH_COMPLETION_PATH} " ]
102
+ then
103
+ mv " ${TEMP_DIR_PATH} /autocomplete/zsh_autocomplete" " ${BASH_COMPLETION_PATH} /_livekit-cli"
104
+ fi
105
+
106
+ if [ -d " ${FISH_COMPLETION_PATH} " ]
107
+ then
108
+ livekit-cli generate-fish-completion -o " ${FISH_COMPLETION_PATH} /livekit-cli.fish"
109
+ fi
110
+ fi
86
111
87
112
log " \n$REPO is installed to $INSTALL_PATH \n"
You can’t perform that action at this time.
0 commit comments