mirror of
https://github.com/packwiz/packwiz.git
synced 2025-10-14 06:54:32 +02:00
-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:
@@ -58,7 +58,7 @@ func init() {
|
||||
defaultCacheDir, err := core.GetPackwizCache()
|
||||
cacheUsage := "The directory where packwiz will cache downloaded mods"
|
||||
if err == nil {
|
||||
cacheUsage += "(default \""+defaultCacheDir+"\")"
|
||||
cacheUsage += "(default \"" + defaultCacheDir + "\")"
|
||||
}
|
||||
rootCmd.PersistentFlags().String("cache", defaultCacheDir, cacheUsage)
|
||||
_ = viper.BindPFlag("cache.directory", rootCmd.PersistentFlags().Lookup("cache"))
|
||||
@@ -70,6 +70,10 @@ func init() {
|
||||
}
|
||||
file = filepath.Join(file, ".packwiz.toml")
|
||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "The config file to use (default \""+file+"\")")
|
||||
|
||||
var nonInteractive bool
|
||||
rootCmd.PersistentFlags().BoolVarP(&nonInteractive, "yes", "y", false, "Accept all prompts with the default or \"yes\" option (non-interactive mode) - may pick unwanted options in search results")
|
||||
_ = viper.BindPFlag("non-interactive", rootCmd.PersistentFlags().Lookup("yes"))
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user