all: remove unused code

And simplify some code too.
This commit is contained in:
Daniel Martí 2018-02-20 13:20:33 +00:00
parent 5ceab57504
commit 73d6f9b1ab
4 changed files with 3 additions and 115 deletions

4
cmd.go
View file

@ -304,7 +304,7 @@ func handleCmd() (err error) {
}
}
if config.SudoLoop == true && cmdArgs.needRoot() {
if config.SudoLoop && cmdArgs.needRoot() {
sudoLoopBackground()
}
@ -665,7 +665,7 @@ func numberMenu(pkgS []string, flags []string) (err error) {
aurI = removeListFromList(aurNI, aurI)
repoI = removeListFromList(repoNI, repoI)
if config.SudoLoop == true {
if config.SudoLoop {
sudoLoopBackground()
}
arguments := makeArguments()

View file

@ -22,15 +22,6 @@ func (set stringSet) remove(v string) {
delete(set, v)
}
func (set stringSet) getAny() string {
for v := range set {
return v
}
//maybe should return error instrad
return ""
}
func (set stringSet) toSlice() []string {
slice := make([]string, 0, len(set))
@ -41,12 +32,6 @@ func (set stringSet) toSlice() []string {
return slice
}
func (set stringSet) removeAny() string {
v := set.getAny()
set.remove(v)
return v
}
type arguments struct {
op string
options map[string]string
@ -381,27 +366,6 @@ func isGlobal(op string) bool {
}
}
func isYayParam(arg string) bool {
switch arg {
case "afterclean":
return true
case "noafterclean":
return true
case "devel":
return true
case "nodevel":
return true
case "timeupdate":
return true
case "notimeupdate":
return true
case "topdown":
return true
default:
return false
}
}
func hasParam(arg string) bool {
switch arg {
case "dbpath", "b":
@ -496,7 +460,7 @@ func (parser *arguments) parseLongOption(arg string, param string) (usedNext boo
}
func (parser *arguments) parseStdin() (err error) {
for true {
for {
var target string
_, err = fmt.Scan(&target)

View file

@ -188,24 +188,6 @@ func printDownloads(repoName string, length int, packages string) {
fmt.Println(repoInfo + yellowFg(packages))
}
func printDeps(repoDeps []string, aurDeps []string) {
if len(repoDeps) != 0 {
fmt.Print(boldGreenFg(arrow + " Repository dependencies: "))
for _, repoD := range repoDeps {
fmt.Print(yellowFg(repoD) + " ")
}
fmt.Print("\n")
}
if len(aurDeps) != 0 {
fmt.Print(boldGreenFg(arrow + " AUR dependencies: "))
for _, aurD := range aurDeps {
fmt.Print(yellowFg(aurD) + " ")
}
fmt.Print("\n")
}
}
// PrintInfo prints package info like pacman -Si.
func PrintInfo(a *rpc.Pkg) {
fmt.Println(boldWhiteFg("Repository :"), "aur")
@ -277,15 +259,6 @@ func localStatistics() error {
return nil
}
//todo make pretty
func printMissing(missing stringSet) {
fmt.Print("Packages not found in repos or aur:")
for pkg := range missing {
fmt.Print(" ", pkg)
}
fmt.Println()
}
//todo make it less hacky
func printNumberOfUpdates() error {
//todo

View file

@ -70,23 +70,6 @@ func filterPackages() (local []alpm.Package, remote []alpm.Package,
return
}
// MissingPackage warns if the Query was unable to find a package
func (q aurQuery) missingPackage(pkgS []string) {
for _, depName := range pkgS {
found := false
for _, dep := range q {
if dep.Name == depName {
found = true
break
}
}
if !found {
fmt.Println(redFg("Unable to find" + depName + "in AUR"))
}
}
}
// NarrowSearch searches AUR and narrows based on subarguments
func narrowSearch(pkgS []string, sortS bool) (aurQuery, error) {
if len(pkgS) == 0 {
@ -327,38 +310,6 @@ func statistics() (info struct {
return
}
// SliceHangingPackages returns a list of packages installed as deps
// and unneeded by the system from a provided list of package names.
func sliceHangingPackages(pkgS []string) (hanging []string) {
localDb, err := alpmHandle.LocalDb()
if err != nil {
return
}
big:
for _, pkgName := range pkgS {
for _, hangN := range hanging {
if hangN == pkgName {
continue big
}
}
pkg, err := localDb.PkgByName(pkgName)
if err == nil {
if pkg.Reason() != alpm.PkgReasonDepend {
continue
}
requiredby := pkg.ComputeRequiredBy()
if len(requiredby) == 0 {
hanging = append(hanging, pkgName)
fmt.Println(pkg.Name() + ": " + yellowFg(human(pkg.ISize())))
}
}
}
return
}
func min(a, b int) int {
if a < b {
return a