Updated the autocomplete file and disable command
This commit is contained in:
parent
b9866d7e90
commit
5ac5070d11
2 changed files with 39 additions and 5 deletions
|
|
@ -5,11 +5,40 @@
|
|||
_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]}"
|
||||
opts="help list add remove clear"
|
||||
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
# 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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,13 +21,18 @@ if builtins.howdy_args.argument == None:
|
|||
sys.exit(1)
|
||||
|
||||
# Translate the argument to the right string
|
||||
if builtins.howdy_args.argument == "1":
|
||||
if builtins.howdy_args.argument == "1" or builtins.howdy_args.argument.lower() == "true":
|
||||
out_value = "true"
|
||||
elif builtins.howdy_args.argument == "0":
|
||||
elif builtins.howdy_args.argument == "0" or builtins.howdy_args.argument.lower() == "false":
|
||||
out_value = "false"
|
||||
else:
|
||||
# Of it's not a 0 or a 1, it's invalid
|
||||
print("Please only use a 0 (enable) or a 1 (disable) as an argument")
|
||||
print("Please only use false (enable) or true (disable) as an argument")
|
||||
sys.exit(1)
|
||||
|
||||
# Don't do anything when the state is already the requested one
|
||||
if out_value == config.get("core", "disabled"):
|
||||
print("The disable option has already been set to " + out_value)
|
||||
sys.exit(1)
|
||||
|
||||
# Loop though the config file and only replace the line containing the disable config
|
||||
|
|
|
|||
Loading…
Reference in a new issue