knqyf263/pet

Add autocompletion for Pet

RamiAwar opened this issue · 1 comments

  • 289.1 ZSH autocompletion plugin
  • 289.2 Contribute completions to zsh-completions library
  • 289.3 Bash autocompletions
  • 289.4 Fish autocompletions

This is not greatly useful for pet users yet, but in doing this I'll gather up some more knowledge about autocompletion and will then be able to judge whether or not it's possible to build autocompletions that rely on dynamic output from pet.

Couldn't tell from basic research, and this is a nice to have anyways.

Still need to look into this, but I have something working.

ZSH autocompletion template:


# Define completion function for the 'pet' command
_pet_complete() {
    local -a pet_commands=("new" "edit" "search" "exec")

    _arguments -C \
        '1: :->command' \
        '*::arg:->args'

    case $state in
        (command)
            # Complete the command based on the list of commands
            _describe 'command' pet_commands
            ;;
        (args)
            # Do nothing for now, you can add additional completions for command arguments here
            ;;
    esac
}

# Register completion function
_zstyle ':completion:*:pet:*' completer _pet_complete

# Call the completion function
_pet_complete "$@"```