andrewgregory / pacutils

Helper library for libalpm based programs.
MIT License
107 stars 17 forks source link

Bash completion for `pacreport` #58

Open sol opened 2 years ago

sol commented 2 years ago

Hey there :wave:

I wrote a bash completion script for pacreport. Please feel free to add it to the repo.

BTW: In the process I noticed two minor issues with the docs:

  1. The man pages erroneously document the --cachedir option as --cache-dir.
  2. --optional-deps is only documented in the man pages, but omitted from the --help output.
# This file is in the public domain.

_pacreport() {
  local cur prev words cword
  _init_completion || return

  local opts='--config --dbext --dbpath --root --sysroot --cachedir --backups --group --missing-files --unowned-files --optional-deps --help --version'

  case "${prev}" in

    # requires file argument
    --config)
      _filedir
      return 0
      ;;

    # requires directory argument
    --root|--sysroot|--cachedir|--dbpath)
      _filedir -d
      return 0
      ;;

    # requires group argument
    --group)
      COMPREPLY=( $(compgen -W "$(pacman -Sgq)" -- ${cur}) )
      return 0
      ;;

    # requires some argument
    --dbext)
      return 0
      ;;

    *)
      COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
      ;;
  esac
}

complete -F _pacreport pacreport

# vim: et:ts=2:sw=2:ft=bash
VorpalBlade commented 2 years ago

This is related to pull request #55 (which adds zsh completion for all the commands). Issue #57 also covers point 2 of the documentation mismatch, though point 1 should be added to it.

Unfortunately it seems this repo is not maintained any more (nothing has happened for some time).