# SPDX-License-Identifier: ISC # smhkd(1) completion for Bash -*- shell-script -*- # # This file is part of smhkd. # # Copyright (C) 2022 Jérémie Roquet # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER # RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE # USE OR PERFORMANCE OF THIS SOFTWARE. _smhkd_command() { COMPREPLY=($(compgen -W 'list run' -- "$1")) } _smhkd_option() { COMPREPLY=($(compgen -W '-h --help --version' -- "$1")) } _smhkd() { if [[ $COMP_CWORD -eq 1 ]]; then local cur=${COMP_WORDS[COMP_CWORD]} if [[ "$cur" = -* ]]; then _smhkd_option "$cur" else _smhkd_command "$cur" fi fi } complete -F _smhkd smhkd