summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-06-23 23:09:47 +0800
committerGitHub <noreply@github.com>2024-06-23 23:09:47 +0800
commitb3bec3cfb0ab75a5dc30dbd55b91e687a3588410 (patch)
treeb9f551fed02d4696a469af499b5755174041000e /scripts
parentf9e7efd41c475519d8f7a01c539d9ee4a3d56208 (diff)
downloadaichat-b3bec3cfb0ab75a5dc30dbd55b91e687a3588410.tar.gz
refactor: cli options and shell completions (#640)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/completions/aichat.bash6
-rw-r--r--scripts/completions/aichat.fish4
-rw-r--r--scripts/completions/aichat.nu6
-rw-r--r--scripts/completions/aichat.ps116
-rw-r--r--scripts/completions/aichat.zsh31
5 files changed, 33 insertions, 30 deletions
diff --git a/scripts/completions/aichat.bash b/scripts/completions/aichat.bash
index 856c6ba..afc81f5 100644
--- a/scripts/completions/aichat.bash
+++ b/scripts/completions/aichat.bash
@@ -19,7 +19,7 @@ _aichat() {
case "${cmd}" in
aichat)
- opts="-m -r -s -b -e -c -f -H -S -w -h -V --model --prompt --role --session --save-session --agent --rag --serve --execute --code --file --no-highlight --no-stream --wrap --light-theme --dry-run --info --list-models --list-roles --list-sessions --list-agents --list-rags --help --version"
+ opts="-m -r -s -a -R -e -c -f -H -S -w -h -V --model --prompt --role --session --save-session --agent --rag --serve --execute --code --file --no-highlight --no-stream --wrap --light-theme --dry-run --info --list-models --list-roles --list-sessions --list-agents --list-rags --help --version"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -61,11 +61,11 @@ _aichat() {
COMPREPLY=($(compgen -W "$("$1" --list-sessions)" -- "${cur}"))
return 0
;;
- -b|--agent)
+ -a|--agent)
COMPREPLY=($(compgen -W "$("$1" --list-agents)" -- "${cur}"))
return 0
;;
- --rag)
+ -R|--rag)
COMPREPLY=($(compgen -W "$("$1" --list-rags)" -- "${cur}"))
return 0
;;
diff --git a/scripts/completions/aichat.fish b/scripts/completions/aichat.fish
index d57f29d..4a926c9 100644
--- a/scripts/completions/aichat.fish
+++ b/scripts/completions/aichat.fish
@@ -3,8 +3,8 @@ complete -c aichat -l prompt -d 'Use the system prompt'
complete -c aichat -s r -l role -x -a "(aichat --list-roles)" -d 'Select a role' -r
complete -c aichat -s s -l session -x -a"(aichat --list-sessions)" -d 'Start or join a session' -r
complete -c aichat -l save-session -d 'Forces the session to be saved'
-complete -c aichat -s b -l agent -x -a"(aichat --list-agents)" -d 'Start a agent' -r
-complete -c aichat -l rag -x -a"(aichat --list-rags)" -d 'Start a RAG' -r
+complete -c aichat -s a -l agent -x -a"(aichat --list-agents)" -d 'Start a agent' -r
+complete -c aichat -s R -l rag -x -a"(aichat --list-rags)" -d 'Start a RAG' -r
complete -c aichat -s f -l file -d 'Include files with the message' -r -F
complete -c aichat -s w -l wrap -d 'Control text wrapping (no, auto, <max-width>)'
complete -c aichat -l serve -d 'Serve the LLM API and WebAPP'
diff --git a/scripts/completions/aichat.nu b/scripts/completions/aichat.nu
index 60f45f9..4a3d189 100644
--- a/scripts/completions/aichat.nu
+++ b/scripts/completions/aichat.nu
@@ -41,8 +41,8 @@ module completions {
--role(-r): string@"nu-complete aichat role" # Select a role
--session(-s): string@"nu-complete aichat role" # Start or join a session
--save-session # Forces the session to be saved
- --agent(-b): string@"nu-complete aichat agent" # Start a agent
- --rag: string@"nu-complete aichat rag" # Start a RAG
+ --agent(-a): string@"nu-complete aichat agent" # Start a agent
+ --rag(-R): string@"nu-complete aichat rag" # Start a RAG
--serve # Serve the LLM API and WebAPP
--execute(-e) # Execute commands in natural language
--code(-c) # Output code only
@@ -56,7 +56,7 @@ module completions {
--list-models # List all available chat models
--list-roles # List all roles
--list-sessions # List all sessions
- --list-agents # List all agents
+ --list-agents # List all agents
--list-rags # List all RAGs
...text: string # Input text
--help(-h) # Print help
diff --git a/scripts/completions/aichat.ps1 b/scripts/completions/aichat.ps1
index ac582d7..dd0dc9c 100644
--- a/scripts/completions/aichat.ps1
+++ b/scripts/completions/aichat.ps1
@@ -28,8 +28,9 @@ Register-ArgumentCompleter -Native -CommandName 'aichat' -ScriptBlock {
[CompletionResult]::new('-s', '-s', [CompletionResultType]::ParameterName, 'Start or join a session')
[CompletionResult]::new('--session', '--session', [CompletionResultType]::ParameterName, 'Start or join a session')
[CompletionResult]::new('--save-session', '--save-session', [CompletionResultType]::ParameterName, 'Forces the session to be saved')
- [CompletionResult]::new('-b', '-b', [CompletionResultType]::ParameterName, 'Start a agent')
+ [CompletionResult]::new('-a', '-a', [CompletionResultType]::ParameterName, 'Start a agent')
[CompletionResult]::new('--agent', '--agent', [CompletionResultType]::ParameterName, 'Start a agent')
+ [CompletionResult]::new('-R', '-R', [CompletionResultType]::ParameterName, 'Start a RAG')
[CompletionResult]::new('--rag', '--rag', [CompletionResultType]::ParameterName, 'Start a RAG')
[CompletionResult]::new('-f', '-f', [CompletionResultType]::ParameterName, 'Include files with the message')
[CompletionResult]::new('--file', '--file', [CompletionResultType]::ParameterName, 'Include files with the message')
@@ -70,17 +71,18 @@ Register-ArgumentCompleter -Native -CommandName 'aichat' -ScriptBlock {
$offset=1
}
$flag = $commandElements[$commandElements.Count-$offset].ToString()
- if ($flag -eq "-m" -or $flag -eq "--model") {
+ dump-args $flag ($flag -eq "-R") > /tmp/file1
+ if ($flag -ceq "-m" -or $flag -eq "--model") {
$completions = Get-AichatValues "--list-models"
- } elseif ($flag -eq "-r" -or $flag -eq "--role") {
+ } elseif ($flag -ceq "-r" -or $flag -eq "--role") {
$completions = Get-AichatValues "--list-roles"
- } elseif ($flag -eq "-s" -or $flag -eq "--session") {
+ } elseif ($flag -ceq "-s" -or $flag -eq "--session") {
$completions = Get-AichatValues "--list-sessions"
- } elseif ($flag -eq "-b" -or $flag -eq "--agent") {
+ } elseif ($flag -ceq "-a" -or $flag -eq "--agent") {
$completions = Get-AichatValues "--list-agents"
- } elseif ($flag -eq "--rag") {
+ } elseif ($flag -ceq "-R" -or $flag -eq "--rag") {
$completions = Get-AichatValues "--list-rags"
- } elseif ($flag -eq "-f" -or $flag -eq "--file") {
+ } elseif ($flag -ceq "-f" -or $flag -eq "--file") {
$completions = @()
}
}
diff --git a/scripts/completions/aichat.zsh b/scripts/completions/aichat.zsh
index 6d8dbc1..45da3ca 100644
--- a/scripts/completions/aichat.zsh
+++ b/scripts/completions/aichat.zsh
@@ -14,22 +14,23 @@ _aichat() {
fi
local context curcontext="$curcontext" state line
- local common=(
-'-m+[Select a LLM model]:MODEL:->models' \
-'--prompt=[Use the system prompt]:PROMPT: ' \
-'--model=[Select a LLM model]:MODEL:->models' \
-'-r+[Select a role]:ROLE:->roles' \
-'--role=[Select a role]:ROLE:->roles' \
-'-s+[Start or join a session]:SESSION:->sessions' \
-'--session=[Start or join a session]:SESSION:->sessions' \
+ local common=(
+'-m[Select a LLM model]:MODEL:->models' \
+'--model[Select a LLM model]:MODEL:->models' \
+'--prompt[Use the system prompt]:PROMPT: ' \
+'-r[Select a role]:ROLE:->roles' \
+'--role[Select a role]:ROLE:->roles' \
+'-s[Start or join a session]:SESSION:->sessions' \
+'--session[Start or join a session]:SESSION:->sessions' \
'--save-session[Forces the session to be saved]' \
-'-b+[Start a agent]:BOT:->agents' \
-'--agent=[Start a agent]:BOT:->agents' \
-'--rag=[Start a RAG]:RAG:->rags' \
-'*-f+[Include files with the message]:FILE:_files' \
-'*--file=[Include files with the message]:FILE:_files' \
-'-w+[Control text wrapping (no, auto, <max-width>)]:WRAP: ' \
-'--wrap=[Control text wrapping (no, auto, <max-width>)]:WRAP: ' \
+'-a[Start a agent]:AGENT:->agents' \
+'--agent[Start a agent]:AGENT:->agents' \
+'-R[Start a RAG]:RAG:->rags' \
+'--rag[Start a RAG]:RAG:->rags' \
+'*-f[Include files with the message]:FILE:_files' \
+'*--file[Include files with the message]:FILE:_files' \
+'-w[Control text wrapping (no, auto, <max-width>)]:WRAP: ' \
+'--wrap[Control text wrapping (no, auto, <max-width>)]:WRAP: ' \
'--serve[Serve the LLM API and WebAPP]' \
'-e[Execute commands in natural language]' \
'--execute[Execute commands in natural language]' \