mirror of
https://github.com/Jguer/yay
synced 2024-10-31 04:12:51 +00:00
Work towards AUR completion. Right now works on fish, very inefficient, one GET for every completion
This commit is contained in:
parent
2bdaec82bc
commit
375f4d74de
3 changed files with 22 additions and 2 deletions
16
actions.go
16
actions.go
|
@ -3,7 +3,9 @@ package yay
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -325,3 +327,17 @@ func GetPkgbuild(pkg string) (err error) {
|
||||||
err = aur.GetPkgbuild(pkg, wd)
|
err = aur.GetPkgbuild(pkg, wd)
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -61,6 +61,9 @@ func parser() (op string, options []string, packages []string, err error) {
|
||||||
util.SortMode = util.BottomUp
|
util.SortMode = util.BottomUp
|
||||||
case "--topdown":
|
case "--topdown":
|
||||||
util.SortMode = util.TopDown
|
util.SortMode = util.TopDown
|
||||||
|
case "--complete":
|
||||||
|
yay.Complete()
|
||||||
|
os.Exit(0)
|
||||||
case "--help":
|
case "--help":
|
||||||
usage()
|
usage()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
5
yay.fish
5
yay.fish
|
@ -1,13 +1,14 @@
|
||||||
# Completions for apacman
|
# Completions for apacman
|
||||||
# Original Author for pacman: Giorgio Lando <patroclo7@gmail.com>
|
# Original Author for pacman: Giorgio Lando <patroclo7@gmail.com>
|
||||||
# Updated for pacman by maxfl, SanskritFritz, faho, f1u77y
|
# Updated for pacman by maxfl, SanskritFritz, faho, f1u77y
|
||||||
# Updated for apacman by jguer
|
# Updated for yay by jguer
|
||||||
|
|
||||||
set -l progname yay
|
set -l progname yay
|
||||||
|
|
||||||
set -l listinstalled "(pacman -Q | string replace ' ' \t)"
|
set -l listinstalled "(pacman -Q | string replace ' ' \t)"
|
||||||
# This might be an issue if another package manager is also installed (e.g. for containers)
|
# This might be an issue if another package manager is also installed (e.g. for containers)
|
||||||
set -l listall "(__fish_print_packages)"
|
set -l listall "(__fish_print_packages)"
|
||||||
|
set -l listaur "(yay --complete)"
|
||||||
set -l listrepos "(__fish_print_pacman_repos)"
|
set -l listrepos "(__fish_print_pacman_repos)"
|
||||||
set -l listgroups "(pacman -Sg)\t'Package Group'"
|
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; 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 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 -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
|
# Database options
|
||||||
set -l has_db_opt '__fish_contains_opt asdeps asexplicit'
|
set -l has_db_opt '__fish_contains_opt asdeps asexplicit'
|
||||||
|
|
Loading…
Reference in a new issue