|
|
|
@ -3,6 +3,7 @@ package main
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/fatih/color"
|
|
|
|
|
|
|
|
|
@ -55,26 +56,34 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
installs = 0
|
|
|
|
|
removes = 0
|
|
|
|
|
updates = 0
|
|
|
|
|
installs []string
|
|
|
|
|
removes []string
|
|
|
|
|
updates []string
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
for _, op := range ops {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
fmt.Printf(" - ")
|
|
|
|
|
|
|
|
|
|
switch op.Type {
|
|
|
|
|
case args.INSTALL:
|
|
|
|
|
fmt.Printf("installing %s", op.Package)
|
|
|
|
|
err = operators.Install(op.Package)
|
|
|
|
|
installs++
|
|
|
|
|
installs = append(installs, op.Package)
|
|
|
|
|
case args.REMOVE:
|
|
|
|
|
fmt.Printf("removing %s", op.Package)
|
|
|
|
|
err = operators.Remove(op.Package)
|
|
|
|
|
removes++
|
|
|
|
|
removes = append(removes, op.Package)
|
|
|
|
|
case args.UPDATE:
|
|
|
|
|
fmt.Printf("updating %s", op.Package)
|
|
|
|
|
err = operators.Update(op.Package)
|
|
|
|
|
updates++
|
|
|
|
|
updates = append(updates, op.Package)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Print(" ")
|
|
|
|
|
color.Green("done")
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
@ -94,7 +103,9 @@ func main() {
|
|
|
|
|
printStat(cyan, "UPDATED", updates)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func printStat(colour *color.Color, prefix string, count int) {
|
|
|
|
|
func printStat(colour *color.Color, prefix string, pkgs []string) {
|
|
|
|
|
count := len(pkgs)
|
|
|
|
|
|
|
|
|
|
if count > 0 {
|
|
|
|
|
colour.Printf("%10s ", prefix)
|
|
|
|
|
|
|
|
|
@ -104,6 +115,6 @@ func printStat(colour *color.Color, prefix string, count int) {
|
|
|
|
|
fmt.Printf("1 package")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Println()
|
|
|
|
|
fmt.Printf(" (%s)\n", strings.Join(pkgs, ", "))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|