diff --git a/actions.go b/actions.go index e4287797..5a2dd3a9 100644 --- a/actions.go +++ b/actions.go @@ -3,7 +3,9 @@ package yay import ( "bufio" "fmt" + "io" "math" + "net/http" "os" "os/exec" "strconv" @@ -325,3 +327,17 @@ func GetPkgbuild(pkg string) (err error) { err = aur.GetPkgbuild(pkg, wd) return } + +func Complete() (err error) { + // Get the data + resp, err := http.Get("https://aur.archlinux.org/packages.gz") + if err != nil { + return err + } + defer resp.Body.Close() + _, err = io.Copy(os.Stdout, resp.Body) + if err != nil { + return err + } + return nil +} diff --git a/cmd/yay/yay.go b/cmd/yay/yay.go index 72933d5b..5b0cfe21 100644 --- a/cmd/yay/yay.go +++ b/cmd/yay/yay.go @@ -61,6 +61,9 @@ func parser() (op string, options []string, packages []string, err error) { util.SortMode = util.BottomUp case "--topdown": util.SortMode = util.TopDown + case "--complete": + yay.Complete() + os.Exit(0) case "--help": usage() os.Exit(0) diff --git a/yay.fish b/yay.fish index 714a6c69..434472e3 100644 --- a/yay.fish +++ b/yay.fish @@ -1,13 +1,14 @@ # Completions for apacman # Original Author for pacman: Giorgio Lando # Updated for pacman by maxfl, SanskritFritz, faho, f1u77y -# Updated for apacman by jguer +# Updated for yay by jguer set -l progname yay set -l listinstalled "(pacman -Q | string replace ' ' \t)" # This might be an issue if another package manager is also installed (e.g. for containers) set -l listall "(__fish_print_packages)" +set -l listaur "(yay --complete)" set -l listrepos "(__fish_print_pacman_repos)" set -l listgroups "(pacman -Sg)\t'Package Group'" @@ -117,7 +118,7 @@ complete -c $progname -n "$sync; and not __fish_contains_opt -s u sysupgrade" -s complete -c $progname -n "$sync; and __fish_contains_opt -s u sysupgrade" -s u -l sysupgrade -d 'Also downgrade packages' complete -c $progname -n $sync -s w -l downloadonly -d 'Only download the target packages' complete -c $progname -n $sync -s y -l refresh -d 'Download fresh copy of the package list' -complete -c $progname -n "$sync" -xa "$listall $listgroups" +complete -c $progname -n "$sync" -xa "$listall $listgroups $listaur" # Database options set -l has_db_opt '__fish_contains_opt asdeps asexplicit'