mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 13:06:30 +02:00
Also makes Modrinth auto-accept search results with only 1 result, to be consistent with CurseForge.
29 lines
526 B
Go
29 lines
526 B
Go
package cmdshared
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"github.com/spf13/viper"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func PromptYesNo(prompt string) bool {
|
|
fmt.Print(prompt)
|
|
if viper.GetBool("non-interactive") {
|
|
fmt.Println("Y (non-interactive mode)")
|
|
return true
|
|
}
|
|
answer, err := bufio.NewReader(os.Stdin).ReadString('\n')
|
|
if err != nil {
|
|
fmt.Printf("Failed to prompt user: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
ansNormal := strings.ToLower(strings.TrimSpace(answer))
|
|
if len(ansNormal) > 0 && ansNormal[0] == 'n' {
|
|
return false
|
|
}
|
|
return true
|
|
}
|