0
0
Fork 0
mirror of https://github.com/boltgolt/howdy.git synced 2024-09-19 09:51:19 +02:00
howdy/autocomplete/howdy
boltgolt 22cc108e87 Added auto config backup and restore for upgarades
This does remove all comments from the config file
2018-05-10 15:05:27 +02:00

46 lines
1 KiB
Bash
Executable file

#!/bin/bash
# Autocomplete file run in bash
# Will sugest arguments on tab
_howdy() {
local cur prev opts
COMPREPLY=()
# The argument typed so far
cur="${COMP_WORDS[COMP_CWORD]}"
# The previous argument
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Go though all cases we support
case "${prev}" in
# After the main command, show the commands
"howdy")
opts="add clear config disable list remove clear test"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
# For disable, grab the current "disabled" config option and give the reverse
"disable")
local status=$(cut -d'=' -f2 <<< $(cat /lib/security/howdy/config.ini | grep 'disabled =') | xargs echo -n)
[ "$status" == "false" ] && COMPREPLY="true" || COMPREPLY="false"
return 0
;;
# List the users availible
"-U")
COMPREPLY=( $(compgen -u -- ${cur}) )
return 0
;;
"--user")
COMPREPLY=( $(compgen -u -- ${cur}) )
return 0
;;
*)
;;
esac
# Nothing matched, so return nothing
return 0
}
# Register the autocomplete function
complete -F _howdy howdy