-y/--yes flag for non-interactive mode (fixes #46)

Also makes Modrinth auto-accept search results with only 1 result, to be
consistent with CurseForge.
This commit is contained in:
comp500
2022-08-25 04:47:18 +01:00
parent 503232a3fa
commit 11671421ac
5 changed files with 63 additions and 36 deletions

View File

@@ -1,14 +1,12 @@
package cmd
import (
"bufio"
"fmt"
"github.com/spf13/viper"
"os"
"strings"
"github.com/packwiz/packwiz/cmdshared"
"github.com/packwiz/packwiz/core"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
)
// updateCmd represents the update command
@@ -101,15 +99,7 @@ var updateCmd = &cobra.Command{
return
}
fmt.Print("Do you want to update? [Y/n]: ")
answer, err := bufio.NewReader(os.Stdin).ReadString('\n')
if err != nil {
fmt.Println(err)
os.Exit(1)
}
ansNormal := strings.ToLower(strings.TrimSpace(answer))
if len(ansNormal) > 0 && ansNormal[0] == 'n' {
if !cmdshared.PromptYesNo("Do you want to update? [Y/n]: ") {
fmt.Println("Cancelled!")
return
}