blob: 260a9d42d6e942610e1b0c0febbd325042844f53 (
plain) (
blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
_aichat() {
local cur prev words cword i opts cmd
COMPREPLY=()
_get_comp_words_by_ref -n : cur prev words cword
for i in ${words[@]}
do
case "${cmd},${i}" in
",$1")
cmd="aichat"
;;
*)
;;
esac
done
case "${cmd}" in
aichat)
opts="-m -r -s -a -R -e -c -f -S -h -V --model --prompt --role --session --empty-session --save-session --agent --rag --serve --execute --code --file --no-stream --dry-run --info --list-models --list-roles --list-sessions --list-agents --list-rags --help --version"
if [[ ${cur} == -* || ${cword} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
-m|--model)
COMPREPLY=($(compgen -W "$("$1" --list-models)" -- "${cur}"))
__ltrim_colon_completions "$cur"
return 0
;;
--prompt)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-r|--role)
COMPREPLY=($(compgen -W "$("$1" --list-roles)" -- "${cur}"))
__ltrim_colon_completions "$cur"
return 0
;;
-s|--session)
COMPREPLY=($(compgen -W "$("$1" --list-sessions)" -- "${cur}"))
__ltrim_colon_completions "$cur"
return 0
;;
-a|--agent)
COMPREPLY=($(compgen -W "$("$1" --list-agents)" -- "${cur}"))
__ltrim_colon_completions "$cur"
return 0
;;
-R|--rag)
COMPREPLY=($(compgen -W "$("$1" --list-rags)" -- "${cur}"))
__ltrim_colon_completions "$cur"
return 0
;;
-f|--file)
local oldifs
if [[ -v IFS ]]; then
oldifs="$IFS"
fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
if [[ -v oldifs ]]; then
IFS="$oldifs"
fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
esac
}
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _aichat -o nosort -o bashdefault -o default aichat
else
complete -F _aichat -o bashdefault -o default aichat
fi
|