mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
342 lines
12 KiB
Bash
342 lines
12 KiB
Bash
# goose-api completion -*- shell-script -*-
|
|
|
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
# !
|
|
# ! Note:
|
|
# !
|
|
# ! THIS SCRIPT HAS BEEN AUTOMATICALLY GENERATED USING
|
|
# ! openapi-generator (https://openapi-generator.tech)
|
|
# ! FROM OPENAPI SPECIFICATION IN JSON.
|
|
# !
|
|
# ! Generator version: 7.14.0
|
|
# !
|
|
# !
|
|
# ! System wide installation:
|
|
# !
|
|
# ! $ sudo cp goose-api.bash-completion /etc/bash-completion.d/goose-api
|
|
# !
|
|
# !
|
|
# ! User home installation (add this line to .bash_profile):
|
|
# !
|
|
# ! [ -r ~/goose-api.bash-completion ] && source ~/goose-api.bash-completion
|
|
# !
|
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
declare -A mime_type_abbreviations
|
|
# text/*
|
|
mime_type_abbreviations["text"]="text/plain"
|
|
mime_type_abbreviations["html"]="text/html"
|
|
mime_type_abbreviations["md"]="text/x-markdown"
|
|
mime_type_abbreviations["csv"]="text/csv"
|
|
mime_type_abbreviations["css"]="text/css"
|
|
mime_type_abbreviations["rtf"]="text/rtf"
|
|
# application/*
|
|
mime_type_abbreviations["json"]="application/json"
|
|
mime_type_abbreviations["xml"]="application/xml"
|
|
mime_type_abbreviations["yaml"]="application/yaml"
|
|
mime_type_abbreviations["js"]="application/javascript"
|
|
mime_type_abbreviations["bin"]="application/octet-stream"
|
|
mime_type_abbreviations["rdf"]="application/rdf+xml"
|
|
# image/*
|
|
mime_type_abbreviations["jpg"]="image/jpeg"
|
|
mime_type_abbreviations["png"]="image/png"
|
|
mime_type_abbreviations["gif"]="image/gif"
|
|
mime_type_abbreviations["bmp"]="image/bmp"
|
|
mime_type_abbreviations["tiff"]="image/tiff"
|
|
|
|
|
|
#
|
|
# Check if this is OSX, if so defined custom init_completion
|
|
#
|
|
if [[ `uname` =~ "Darwin" ]]; then
|
|
__osx_init_completion()
|
|
{
|
|
COMPREPLY=()
|
|
_get_comp_words_by_ref cur prev words cword
|
|
}
|
|
fi
|
|
|
|
_goose-api()
|
|
{
|
|
local cur
|
|
local prev
|
|
local words
|
|
local cword
|
|
|
|
# The reference of currently selected REST operation
|
|
local operation=""
|
|
|
|
# The list of available operation in the REST service
|
|
# It's modelled as an associative array for efficient key lookup
|
|
declare -A operations
|
|
operations["manageContext"]=1
|
|
operations["createRecipe"]=1
|
|
operations["decodeRecipe"]=1
|
|
operations["deleteRecipe"]=1
|
|
operations["encodeRecipe"]=1
|
|
operations["listRecipes"]=1
|
|
operations["scanRecipe"]=1
|
|
operations["createSchedule"]=1
|
|
operations["deleteSchedule"]=1
|
|
operations["inspectRunningJob"]=1
|
|
operations["killRunningJob"]=1
|
|
operations["listSchedules"]=1
|
|
operations["pauseSchedule"]=1
|
|
operations["runNowHandler"]=1
|
|
operations["sessionsHandler"]=1
|
|
operations["unpauseSchedule"]=1
|
|
operations["updateSchedule"]=1
|
|
operations["deleteSession"]=1
|
|
operations["getSession"]=1
|
|
operations["getSessionInsights"]=1
|
|
operations["listSessions"]=1
|
|
operations["updateSessionDescription"]=1
|
|
operations["addSubRecipes"]=1
|
|
operations["extendPrompt"]=1
|
|
operations["getTools"]=1
|
|
operations["resumeAgent"]=1
|
|
operations["startAgent"]=1
|
|
operations["updateAgentProvider"]=1
|
|
operations["updateRouterToolSelector"]=1
|
|
operations["updateSessionConfig"]=1
|
|
operations["addExtension"]=1
|
|
operations["backupConfig"]=1
|
|
operations["createCustomProvider"]=1
|
|
operations["getExtensions"]=1
|
|
operations["getProviderModels"]=1
|
|
operations["initConfig"]=1
|
|
operations["providers"]=1
|
|
operations["readAllConfig"]=1
|
|
operations["readConfig"]=1
|
|
operations["recoverConfig"]=1
|
|
operations["removeConfig"]=1
|
|
operations["removeCustomProvider"]=1
|
|
operations["removeExtension"]=1
|
|
operations["upsertConfig"]=1
|
|
operations["upsertPermissions"]=1
|
|
operations["validateConfig"]=1
|
|
operations["status"]=1
|
|
operations["confirmPermission"]=1
|
|
operations["startOpenrouterSetup"]=1
|
|
operations["startTetrateSetup"]=1
|
|
|
|
# An associative array of operations to their parameters
|
|
# Only include path, query and header parameters
|
|
declare -A operation_parameters
|
|
operation_parameters["manageContext"]=""
|
|
operation_parameters["createRecipe"]=""
|
|
operation_parameters["decodeRecipe"]=""
|
|
operation_parameters["deleteRecipe"]=""
|
|
operation_parameters["encodeRecipe"]=""
|
|
operation_parameters["listRecipes"]=""
|
|
operation_parameters["scanRecipe"]=""
|
|
operation_parameters["createSchedule"]=""
|
|
operation_parameters["deleteSchedule"]="id= "
|
|
operation_parameters["inspectRunningJob"]="id= "
|
|
operation_parameters["killRunningJob"]="id= "
|
|
operation_parameters["listSchedules"]=""
|
|
operation_parameters["pauseSchedule"]="id= "
|
|
operation_parameters["runNowHandler"]="id= "
|
|
operation_parameters["sessionsHandler"]="id= limit= "
|
|
operation_parameters["unpauseSchedule"]="id= "
|
|
operation_parameters["updateSchedule"]="id= "
|
|
operation_parameters["deleteSession"]="session_id= "
|
|
operation_parameters["getSession"]="session_id= "
|
|
operation_parameters["getSessionInsights"]=""
|
|
operation_parameters["listSessions"]=""
|
|
operation_parameters["updateSessionDescription"]="session_id= "
|
|
operation_parameters["addSubRecipes"]=""
|
|
operation_parameters["extendPrompt"]=""
|
|
operation_parameters["getTools"]="extension_name= session_id= "
|
|
operation_parameters["resumeAgent"]=""
|
|
operation_parameters["startAgent"]=""
|
|
operation_parameters["updateAgentProvider"]=""
|
|
operation_parameters["updateRouterToolSelector"]=""
|
|
operation_parameters["updateSessionConfig"]=""
|
|
operation_parameters["addExtension"]=""
|
|
operation_parameters["backupConfig"]=""
|
|
operation_parameters["createCustomProvider"]=""
|
|
operation_parameters["getExtensions"]=""
|
|
operation_parameters["getProviderModels"]="name= "
|
|
operation_parameters["initConfig"]=""
|
|
operation_parameters["providers"]=""
|
|
operation_parameters["readAllConfig"]=""
|
|
operation_parameters["readConfig"]=""
|
|
operation_parameters["recoverConfig"]=""
|
|
operation_parameters["removeConfig"]=""
|
|
operation_parameters["removeCustomProvider"]="id= "
|
|
operation_parameters["removeExtension"]="name= "
|
|
operation_parameters["upsertConfig"]=""
|
|
operation_parameters["upsertPermissions"]=""
|
|
operation_parameters["validateConfig"]=""
|
|
operation_parameters["status"]=""
|
|
operation_parameters["confirmPermission"]=""
|
|
operation_parameters["startOpenrouterSetup"]=""
|
|
operation_parameters["startTetrateSetup"]=""
|
|
|
|
# An associative array of possible values for enum parameters
|
|
declare -A operation_parameters_enum_values
|
|
|
|
#
|
|
# Check if this is OSX and use special __osx_init_completion function
|
|
#
|
|
if [[ `uname` =~ "Darwin" ]]; then
|
|
__osx_init_completion || return
|
|
else
|
|
_init_completion -s || return
|
|
fi
|
|
|
|
|
|
# Check if operation is already in the command line provided
|
|
for word in "${words[@]}"; do
|
|
if [[ -n $word && ${operations[$word]} ]]; then
|
|
operation="${word}"
|
|
fi
|
|
done
|
|
|
|
if [[ -z $operation ]]; then
|
|
case $prev in
|
|
--ciphers|--connect-timeout|-C|--continue-at|-F|--form|--form-string|\
|
|
--ftp-account|--ftp-alternative-to-user|-P|--ftp-port|-H|--header|-h|\
|
|
--help|--hostpubmd5|--keepalive-time|--krb|--limit-rate|--local-port|\
|
|
--mail-from|--mail-rcpt|--max-filesize|--max-redirs|-m|--max-time|\
|
|
--pass|--proto|--proto-redir|--proxy-user|--proxy1.0|-Q|--quote|-r|\
|
|
--range|-X|--request|--retry|--retry-delay|--retry-max-time|\
|
|
--socks5-gssapi-service|-t|--telnet-option|--tftp-blksize|-z|\
|
|
--time-cond|--url|-u|--user|-A|--user-agent|-V|--version|-w|\
|
|
--write-out|--resolve|--tlsuser|--tlspassword|--about)
|
|
return
|
|
;;
|
|
-K|--config|-b|--cookie|-c|--cookie-jar|-D|--dump-header|--egd-file|\
|
|
--key|--libcurl|-o|--output|--random-file|-T|--upload-file|--trace|\
|
|
--trace-ascii|--netrc-file)
|
|
_filedir
|
|
return
|
|
;;
|
|
--cacert|-E|--cert)
|
|
_filedir '@(c?(e)rt|cer|pem|der)'
|
|
return
|
|
;;
|
|
--capath)
|
|
_filedir -d
|
|
return
|
|
;;
|
|
--cert-type|--key-type)
|
|
COMPREPLY=( $( compgen -W 'DER PEM ENG' -- "$cur" ) )
|
|
return
|
|
;;
|
|
--crlfile)
|
|
_filedir crl
|
|
return
|
|
;;
|
|
-d|--data|--data-ascii|--data-binary|--data-urlencode)
|
|
if [[ $cur == \@* ]]; then
|
|
cur=${cur:1}
|
|
_filedir
|
|
COMPREPLY=( "${COMPREPLY[@]/#/@}" )
|
|
fi
|
|
return
|
|
;;
|
|
--delegation)
|
|
COMPREPLY=( $( compgen -W 'none policy always' -- "$cur" ) )
|
|
return
|
|
;;
|
|
--engine)
|
|
COMPREPLY=( $( compgen -W 'list' -- "$cur" ) )
|
|
return
|
|
;;
|
|
--ftp-method)
|
|
COMPREPLY=( $( compgen -W 'multicwd nocwd singlecwd' -- "$cur" ) )
|
|
return
|
|
;;
|
|
--ftp-ssl-ccc-mode)
|
|
COMPREPLY=( $( compgen -W 'active passive' -- "$cur" ) )
|
|
return
|
|
;;
|
|
--interface)
|
|
_available_interfaces -a
|
|
return
|
|
;;
|
|
-x|--proxy|--socks4|--socks4a|--socks5|--socks5-hostname)
|
|
_known_hosts_real
|
|
return
|
|
;;
|
|
--pubkey)
|
|
_filedir pub
|
|
return
|
|
;;
|
|
--stderr)
|
|
COMPREPLY=( $( compgen -W '-' -- "$cur" ) )
|
|
_filedir
|
|
return
|
|
;;
|
|
--tlsauthtype)
|
|
COMPREPLY=( $( compgen -W 'SRP' -- "$cur" ) )
|
|
return
|
|
;;
|
|
--host)
|
|
COMPREPLY=( $( compgen -W 'http:// https://' -- "$cur" ) )
|
|
return
|
|
;;
|
|
-ct|--content-type|-ac|--accept)
|
|
COMPREPLY=( $( compgen -W '${!mime_type_abbreviations[*]}' -- "$cur" ) )
|
|
return
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
#
|
|
# Complete the server address based on ~/.ssh/known_hosts
|
|
# and ~/.ssh/config
|
|
#
|
|
local prefix=${COMP_WORDS[COMP_CWORD-2]}
|
|
local colon=${COMP_WORDS[COMP_CWORD-1]}
|
|
if [[ "$colon" == ":" && ( $prefix == "https" || $prefix == "http" ) ]]; then
|
|
COMPREPLY=()
|
|
local comp_ssh_hosts=`[[ -f ~/.ssh/known_hosts ]] && \
|
|
( cat ~/.ssh/known_hosts | \
|
|
grep '^[a-zA-Z0-9]' | \
|
|
cut -f 1 -d ' ' | \
|
|
sed -e s/,.*//g | \
|
|
grep -v ^# | \
|
|
uniq | \
|
|
grep -v "\[" ) ;
|
|
[[ -f ~/.ssh/config ]] && \
|
|
( cat ~/.ssh/config | \
|
|
grep "^Host " | \
|
|
awk '{print $2}' )`
|
|
COMPREPLY=( $( compgen -P '//' -W '${comp_ssh_hosts}' -- "${cur:2}") )
|
|
return
|
|
fi
|
|
|
|
#
|
|
# Complete the goose-api and cURL's arguments
|
|
#
|
|
if [[ $cur == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$(_parse_help curl) $(_parse_help $1)' -- "$cur" ) )
|
|
return
|
|
fi
|
|
|
|
#
|
|
# If the argument starts with a letter this could be either an operation
|
|
# or an operation parameter
|
|
# When $cur is empty, suggest the list of operations by default
|
|
#
|
|
if [[ $cur =~ ^[A-Za-z_0-9]* ]]; then
|
|
# If operation has not been yet selected, suggest the list of operations
|
|
# otherwise suggest arguments of this operation as declared in the
|
|
# OpenAPI specification
|
|
if [[ -z $operation ]]; then
|
|
COMPREPLY=( $(compgen -W '${!operations[*]}' -- ${cur}) )
|
|
else
|
|
COMPREPLY=( $(compgen -W '${operation_parameters[$operation]}' -- ${cur}) )
|
|
compopt -o nospace
|
|
fi
|
|
return
|
|
fi
|
|
|
|
} &&
|
|
complete -F _goose-api goose-api
|
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|