Files
jaildk/jaildk-completion.bash
2023-09-12 19:15:45 +02:00

398 lines
10 KiB
Bash

JAILDIR=/jail
# This file is generated by [bash-completor](https://github.com/adoyle-h/bash-completor/tree/v0.1.0). Do not modify it manually.
#
# [Usage]
# Put "source _jaildk-completion.bash" in your bashrc.
#
# If you want to debug the completion.
# Search '# Uncomment this line for debug' line in this file.
#
# [Update Script]
# bash-completor -c completions.sh
# shellcheck disable=2207
# editorconfig-checker-disable
_jaildk_comp_cmd_opts=( )
_jaildk_comp_subcmd_opts_base=( -b -w )
_jaildk_comp_subcmd_opts_build=( -b -v -m )
_jaildk_comp_subcmd_opts_clone=( -s -d -o -n )
_jaildk_comp_subcmd_opts_fetchports=( -v )
_jaildk_comp_subcmd_opts_freeze=( -a -b -v )
_jaildk_comp_subcmd_opts_install=( -m -r )
_jaildk_comp_subcmd_opts_ipfw=( -m )
_jaildk_comp_subcmd_opts_prune=( -b -a -j )
_jaildk_comp_subcmd_opts_rc=( -m -r )
_jaildk_comp_subcmd_opts_reinstall=( -b -v )
_jaildk_comp_subcmd_opts_status=( -v )
_jaildk_comp_subcmd_opts_uninstall=( -w )
_jaildk_comp_subcmd_opts_update=( -f )
declare -A _jaildk_comp_word_to_varname=()
_jaildk_comp_util_get_varname ()
{
local name=${1:-};
local encoded=${_jaildk_comp_word_to_varname[$name]:-};
if [[ -z ${encoded} ]]; then
encoded=${name//[^a-zA-Z_]/_};
fi;
echo "${encoded}"
}
_jaildk_comp_reply_base ()
{
local bases=$(ls $JAILDIR/base);
COMPREPLY=($(compgen -W "${bases[*]}" -- "$cur"))
}
_jaildk_comp_reply_dirs ()
{
local IFS=$'\n';
compopt -o nospace -o filenames;
COMPREPLY=($(compgen -A directory -- "$cur"))
}
_jaildk_comp_reply_files ()
{
local IFS=$'\n';
compopt -o nospace -o filenames;
COMPREPLY=($(compgen -A file -- "$cur"))
}
_jaildk_comp_reply_files_in_pattern ()
{
compopt -o nospace -o filenames;
local path;
while read -r path; do
if [[ $path =~ $1 ]] || [[ -d $path ]]; then
COMPREPLY+=("$path");
fi;
done < <(compgen -A file -- "$cur")
}
_jaildk_comp_reply_jail ()
{
local jails=$(ls $JAILDIR/etc);
COMPREPLY=($(compgen -W "${jails[*]}" -- "$cur"))
}
_jaildk_comp_reply_list ()
{
local IFS=', ';
local array_list="" array_name;
for array_name in $@;
do
array_list="$array_list \${${array_name}[*]}";
done;
array_list="${array_list[*]:1}";
IFS=$'\n'' ';
eval "COMPREPLY=( \$(compgen -W \"$array_list\" -- \"\$cur\") )"
}
_jaildk_comp_reply_version ()
{
local versions=$(ls -d $JAILDIR/etc/*/etc-*|cut -d- -f2 | sort -u);
COMPREPLY=($(compgen -W "${versions[*]}" -- "$cur"))
}
_jaildk_comp_reply_words ()
{
local IFS=$'\n';
COMPREPLY=($(IFS=', ' compgen -W "$*" -- "${cur#=}"))
}
_jaildk_comp_reply_set() {
local IFS=', '
local array_list="" array_name
# shellcheck disable=2068
for array_name in $@; do
array_list="$array_list \${_jaildk_comp_var_${array_name}[*]}"
done
array_list="${array_list[*]:1}"
IFS=$'\n'' '
eval "COMPREPLY=( \$(compgen -W \"$array_list\" -- \"\$cur\") )"
}
_jaildk_comp_subcmds=( base build create clone fetchports install uninstall remove reinstall prune start stop restart status rc ipfw login blogin freeze thaw help version update )
_jaildk_completions_base() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_base
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
*) _jaildk_comp_reply_files ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_files
fi
}
_jaildk_completions_build() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_build
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
-b) _jaildk_comp_reply_base ;;
-v) _jaildk_comp_reply_version ;;
-m) _jaildk_comp_reply_words 'start,stop,status,restart' ;;
*) _jaildk_comp_reply_jail ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_jail
fi
}
_jaildk_completions_clone() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_clone
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
-s) _jaildk_comp_reply_jail ;;
-d) _jaildk_comp_reply_jail ;;
-o) _jaildk_comp_reply_version ;;
-n) _jaildk_comp_reply_version ;;
*) _jaildk_comp_reply_files ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_files
fi
}
_jaildk_completions_fetchports() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_fetchports
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
-v) _jaildk_comp_reply_version ;;
*) _jaildk_comp_reply_files ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_files
fi
}
_jaildk_completions_install() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_install
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
-m) _jaildk_comp_reply_words 'start,stop,status,restart' ;;
-r) _jaildk_comp_reply_words 'mount,ports,mtree,pf' ;;
*) _jaildk_comp_reply_jail ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_jail
fi
}
_jaildk_completions_uninstall() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_uninstall
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
*) _jaildk_comp_reply_jail ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_jail
fi
}
_jaildk_completions_reinstall() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_reinstall
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
-b) _jaildk_comp_reply_base ;;
-v) _jaildk_comp_reply_version ;;
*) _jaildk_comp_reply_jail ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_jail
fi
}
_jaildk_completions_prune() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_prune
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
-j) _jaildk_comp_reply_jail ;;
*) _jaildk_comp_reply_files ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_files
fi
}
_jaildk_completions_status() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_status
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
*) _jaildk_comp_reply_jail ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_jail
fi
}
_jaildk_completions_rc() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_rc
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
-m) _jaildk_comp_reply_words 'start,stop,status,restart' ;;
-r) _jaildk_comp_reply_words 'mount,ports,mtree,pf' ;;
*) _jaildk_comp_reply_files ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_files
fi
}
_jaildk_completions_ipfw() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_ipfw
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
-m) _jaildk_comp_reply_words 'start,stop,status,restart' ;;
*) _jaildk_comp_reply_jail ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_jail
fi
}
_jaildk_completions_freeze() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_freeze
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
-v) _jaildk_comp_reply_version ;;
*) _jaildk_comp_reply_jail ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_jail
fi
}
_jaildk_completions_update() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts_update
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
*) _jaildk_comp_reply_files ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_files
fi
}
_jaildk_completions__fallback() {
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_subcmd_opts__fallback
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
*) _jaildk_comp_reply_files ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_files
fi
}
_jaildk_completions() {
COMPREPLY=()
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
# Uncomment this line for debug
# echo "[COMP_CWORD:$COMP_CWORD][cur:$cur][prev:$prev][WORD_COUNT:${#COMP_WORDS[*]}][COMP_WORDS:${COMP_WORDS[*]}]" >> bash-debug.log
if (( COMP_CWORD > 1 )); then
# Enter the subcmd completion
local subcmd_varname
subcmd_varname="$(_jaildk_comp_util_get_varname "${COMP_WORDS[1]}")"
if type "_jaildk_completions_$subcmd_varname" &>/dev/null; then
"_jaildk_completions_$subcmd_varname"
else
# If subcmd completion function not defined, use the fallback
"_jaildk_completions__fallback"
fi
return 0
fi
# Enter the cmd completion
if [[ ${cur:0:1} == [-+] ]]; then
# rely options of command
_jaildk_comp_reply_list _jaildk_comp_cmd_opts
elif [[ ${prev:0:1} == [-+] ]]; then
case "${prev}" in
# rely the value of command option
*) _jaildk_comp_reply_files ;;
esac
else
# rely the argument of command
_jaildk_comp_reply_list _jaildk_comp_subcmds
fi
}
complete -F _jaildk_completions -o bashdefault jaildk
# vi: sw=2 ts=2