package main
import (
- "bufio"
"fmt"
"os"
- "strings"
)
func MainGlobalUpdate(unused *XSAMeta, args []string) int {
return 1
}
- fmt.Printf("Creating new global metadata\nOldest security-supported xen release: ")
- input := bufio.NewScanner(os.Stdin)
- if !input.Scan() {
- fmt.Printf("Input error\n")
+ fmt.Printf("Creating new global metadata\n")
+ s, err := Query("Oldest security-supported xen release: ")
+ if err != nil {
+ fmt.Printf("Error: %v\n", err)
return 1
}
- s := input.Text()
- // Get rid of newline at the end
- s = strings.NewReplacer("\n", "").Replace(s)
limit = XenVersion(s)
if !limit.Check() {
package main
import (
+ "bufio"
"fmt"
"os"
"strconv"
+ "strings"
)
func OpenRepos() (err error) {
return main(&xsa, args)
}
+var Q struct {
+ real bool
+ testResponses []string
+ trIndex int
+}
+
+func Query(query string) (resp string, err error) {
+ if Q.real {
+ fmt.Print(query)
+ input := bufio.NewScanner(os.Stdin)
+ if !input.Scan() {
+ err = fmt.Errorf("Input error\n")
+ return
+ }
+ s := input.Text()
+ // Get rid of newline at the end
+ resp = strings.NewReplacer("\n", "").Replace(s)
+ } else {
+ // This will panic if we ask for a query beyond the index; that's what we want
+ resp = Q.testResponses[Q.trIndex]
+ Q.trIndex++
+ }
+ return
+}
+
+func QuerySetResponses(responses []string) {
+ // Copy the contents of the slice
+ Q.testResponses = append([]string{}, responses...)
+ Q.trIndex = 0
+}
+
func main() {
+ Q.real = true
os.Exit(XsaMain(os.Args))
}