Browse Source

Use a question callback for ignorepkg

The callback is set to allways silently say yes, When passing to pacman
for the intall pacman will then ask the question giving the user
a chance to answer.
morganamilo 7 years ago
parent
commit
c091460d8c
3 changed files with 15 additions and 1 deletions
  1. 12 0
      callbacks.go
  2. 2 0
      cmd.go
  3. 1 1
      install.go

+ 12 - 0
callbacks.go

@@ -0,0 +1,12 @@
+package main
+
+import (
+	alpm "github.com/jguer/go-alpm"
+)
+
+func QuestionCallback(question alpm.QuestionAny) {
+	q, err := question.QuestionInstallIgnorepkg()
+	if err == nil {
+		q.SetInstall(true)
+	}
+}

+ 2 - 0
cmd.go

@@ -223,6 +223,8 @@ func initAlpm() (err error) {
 		return
 	}
 
+	alpmHandle.SetQuestionCallback(QuestionCallback)
+
 	return
 }
 

+ 1 - 1
install.go

@@ -184,7 +184,7 @@ func install(parser *arguments) error {
 
 		//conflicts have been checked so answer y for them
 		ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
-		uask := alpm.Question(ask) | alpm.QuestionConflictPkg
+		uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
 		cmdArgs.globals["ask"] = fmt.Sprint(uask)
 
 		//this downloads the package build sources but also causes