mirror of
https://github.com/Jguer/yay
synced 2024-10-02 22:33:47 +00:00
Added yay cmd
This commit is contained in:
parent
84de22df45
commit
517939d108
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -26,4 +26,3 @@ _testmain.go
|
|||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
bin/yay
|
||||
yay
|
||||
|
|
92
cmd/yay/yay.go
Normal file
92
cmd/yay/yay.go
Normal file
|
@ -0,0 +1,92 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/jguer/yay"
|
||||
)
|
||||
|
||||
func usage() {
|
||||
fmt.Println(`usage: yay <operation> [...]
|
||||
operations:
|
||||
yay {-h --help}
|
||||
yay {-V --version}
|
||||
yay {-D --database} <options> <package(s)>
|
||||
yay {-F --files} [options] [package(s)]
|
||||
yay {-Q --query} [options] [package(s)]
|
||||
yay {-R --remove} [options] <package(s)>
|
||||
yay {-S --sync} [options] [package(s)]
|
||||
yay {-T --deptest} [options] [package(s)]
|
||||
yay {-U --upgrade} [options] <file(s)>
|
||||
|
||||
New operations:
|
||||
yay -Qstats - Displays system information
|
||||
`)
|
||||
}
|
||||
|
||||
func parser() (op string, options []string, packages []string, err error) {
|
||||
if len(os.Args) < 2 {
|
||||
err = fmt.Errorf("no operation specified")
|
||||
return
|
||||
}
|
||||
|
||||
for _, arg := range os.Args[1:] {
|
||||
if arg[0] == '-' && arg[1] != '-' {
|
||||
op = arg
|
||||
}
|
||||
|
||||
if arg[0] == '-' && arg[1] == '-' {
|
||||
if arg == "--help" {
|
||||
op = arg
|
||||
}
|
||||
options = append(options, arg)
|
||||
}
|
||||
|
||||
if arg[0] != '-' {
|
||||
packages = append(packages, arg)
|
||||
}
|
||||
}
|
||||
|
||||
if op == "" {
|
||||
op = "yogurt"
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
op, options, pkgs, err := parser()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
switch op {
|
||||
case "-Qstats":
|
||||
err = yay.LocalStatistics()
|
||||
case "-Ss":
|
||||
for _, pkg := range pkgs {
|
||||
err = searchMode(pkg, &conf)
|
||||
}
|
||||
case "-S":
|
||||
err = InstallPackage(pkgs, &conf, options)
|
||||
case "-Syu", "-Suy":
|
||||
err = yay.Upgrade(options)
|
||||
case "yogurt":
|
||||
for _, pkg := range pkgs {
|
||||
err = yay.NumberMenu(pkg, &conf, options)
|
||||
break
|
||||
}
|
||||
case "--help", "-h":
|
||||
usage()
|
||||
default:
|
||||
err = passToPacman(op, pkgs, options)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue