Skip to content

Commit

Permalink
fix(noconfirm): move noconfirm to config global
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Aug 18, 2020
1 parent 9ad2862 commit 7b70462
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func syncClean(cmdArgs *settings.Arguments, dbExecutor db.Executor) error {

fmt.Println(gotext.Get("\nBuild directory:"), config.BuildDir)

if text.ContinueTask(question, true, config.NoConfirm) {
if text.ContinueTask(question, true, settings.NoConfirm) {
if err := cleanAUR(keepInstalled, keepCurrent, removeAll, dbExecutor); err != nil {
return err
}
Expand All @@ -103,7 +103,7 @@ func syncClean(cmdArgs *settings.Arguments, dbExecutor db.Executor) error {
return nil
}

if text.ContinueTask(gotext.Get("Do you want to remove ALL untracked AUR files?"), true, config.NoConfirm) {
if text.ContinueTask(gotext.Get("Do you want to remove ALL untracked AUR files?"), true, settings.NoConfirm) {
return cleanUntracked()
}

Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func editor() (editor string, args []string) {

func getInput(defaultValue string) (string, error) {
text.Info()
if defaultValue != "" || config.NoConfirm {
if defaultValue != "" || settings.NoConfirm {
fmt.Println(defaultValue)
return defaultValue, nil
}
Expand Down
2 changes: 1 addition & 1 deletion exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func passToPacman(args *settings.Arguments) *exec.Cmd {
argArr = append(argArr, config.PacmanBin)
argArr = append(argArr, args.FormatGlobals()...)
argArr = append(argArr, args.FormatArgs()...)
if config.NoConfirm {
if settings.NoConfirm {
argArr = append(argArr, "--noconfirm")
}

Expand Down
44 changes: 22 additions & 22 deletions install.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider

dp, err := dep.GetPool(requestTargets,
warnings, dbExecutor, config.Runtime.Mode,
ignoreProviders, config.NoConfirm, config.Provides, config.ReBuild, config.RequestSplitN)
ignoreProviders, settings.NoConfirm, config.Provides, config.ReBuild, config.RequestSplitN)
if err != nil {
return err
}
Expand Down Expand Up @@ -186,7 +186,7 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider

var conflicts stringset.MapStringSet
if !cmdArgs.ExistsDouble("d", "nodeps") {
conflicts, err = dp.CheckConflicts(config.UseAsk, config.NoConfirm)
conflicts, err = dp.CheckConflicts(config.UseAsk, settings.NoConfirm)
if err != nil {
return err
}
Expand Down Expand Up @@ -227,7 +227,7 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider
case "no":
break
default:
if text.ContinueTask(gotext.Get("Remove make dependencies after install?"), false, config.NoConfirm) {
if text.ContinueTask(gotext.Get("Remove make dependencies after install?"), false, settings.NoConfirm) {
defer func() {
err = removeMake(do)
}()
Expand Down Expand Up @@ -272,18 +272,18 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider
}

if len(toDiff) > 0 {
oldValue := config.NoConfirm
config.NoConfirm = false
oldValue := settings.NoConfirm
settings.NoConfirm = false
fmt.Println()
if !text.ContinueTask(gotext.Get("Proceed with install?"), true, config.NoConfirm) {
if !text.ContinueTask(gotext.Get("Proceed with install?"), true, settings.NoConfirm) {
return fmt.Errorf(gotext.Get("aborting due to user"))
}
err = updatePkgbuildSeenRef(toDiff)
if err != nil {
text.Errorln(err.Error())
}

config.NoConfirm = oldValue
settings.NoConfirm = oldValue
}

err = mergePkgbuilds(do.Aur)
Expand Down Expand Up @@ -312,13 +312,13 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider
}

if len(toEdit) > 0 {
oldValue := config.NoConfirm
config.NoConfirm = false
oldValue := settings.NoConfirm
settings.NoConfirm = false
fmt.Println()
if !text.ContinueTask(gotext.Get("Proceed with install?"), true, config.NoConfirm) {
if !text.ContinueTask(gotext.Get("Proceed with install?"), true, settings.NoConfirm) {
return errors.New(gotext.Get("aborting due to user"))
}
config.NoConfirm = oldValue
settings.NoConfirm = oldValue
}

incompatible, err = getIncompatible(do.Aur, srcinfos, dbExecutor)
Expand All @@ -327,7 +327,7 @@ func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProvider
}

if config.PGPFetch {
err = pgp.CheckPgpKeys(do.Aur, srcinfos, config.GpgBin, config.GpgFlags, config.NoConfirm)
err = pgp.CheckPgpKeys(do.Aur, srcinfos, config.GpgBin, config.GpgFlags, settings.NoConfirm)
if err != nil {
return err
}
Expand Down Expand Up @@ -394,10 +394,10 @@ func removeMake(do *dep.Order) error {
removeArguments.AddTarget(pkg)
}

oldValue := config.NoConfirm
config.NoConfirm = true
oldValue := settings.NoConfirm
settings.NoConfirm = true
err = show(passToPacman(removeArguments))
config.NoConfirm = oldValue
settings.NoConfirm = oldValue

return err
}
Expand Down Expand Up @@ -487,7 +487,7 @@ nextpkg:

fmt.Println()

if !text.ContinueTask(gotext.Get("Try to build them anyway?"), true, config.NoConfirm) {
if !text.ContinueTask(gotext.Get("Try to build them anyway?"), true, settings.NoConfirm) {
return nil, errors.New(gotext.Get("aborting due to user"))
}
}
Expand Down Expand Up @@ -954,8 +954,8 @@ func buildInstallPkgbuilds(

deps := make([]string, 0)
exp := make([]string, 0)
oldConfirm := config.NoConfirm
config.NoConfirm = true
oldConfirm := settings.NoConfirm
settings.NoConfirm = true

//remotenames: names of all non repo packages on the system
localNames, remoteNames, err := query.GetPackageNamesBySource(dbExecutor)
Expand Down Expand Up @@ -989,12 +989,12 @@ func buildInstallPkgbuilds(
return errExps
}

config.NoConfirm = oldConfirm
settings.NoConfirm = oldConfirm

arguments.ClearTargets()
deps = make([]string, 0)
exp = make([]string, 0)
config.NoConfirm = true
settings.NoConfirm = true
return nil
}

Expand Down Expand Up @@ -1107,7 +1107,7 @@ func buildInstallPkgbuilds(
} else {
for _, split := range base {
if _, ok := conflicts[split.Name]; ok {
config.NoConfirm = false
settings.NoConfirm = false
break
}
}
Expand Down Expand Up @@ -1167,6 +1167,6 @@ func buildInstallPkgbuilds(
}

err = doInstall()
config.NoConfirm = oldConfirm
settings.NoConfirm = oldConfirm
return err
}
8 changes: 4 additions & 4 deletions pkg/db/ialpm/alpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ func (ae *AlpmExecutor) questionCallback() func(question alpm.QuestionAny) {
fmt.Print(gotext.Get("\nEnter a number (default=1): "))

// TODO: reenable noconfirm
// if config.NoConfirm {
// fmt.Println()
// break
// }
if settings.NoConfirm {
fmt.Println()
break
}

reader := bufio.NewReader(os.Stdin)
numberBuf, overflow, err := reader.ReadLine()
Expand Down
5 changes: 3 additions & 2 deletions pkg/settings/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const (
// HideMenus indicates if pacman's provider menus must be hidden
var HideMenus = false

// NoConfirm indicates if user input should be skipped
var NoConfirm = false

// Configuration stores yay's config.
type Configuration struct {
AURURL string `json:"aururl"`
Expand Down Expand Up @@ -49,7 +52,6 @@ type Configuration struct {
CompletionInterval int `json:"completionrefreshtime"`
SudoLoop bool `json:"sudoloop"`
TimeUpdate bool `json:"timeupdate"`
NoConfirm bool `json:"-"`
Devel bool `json:"devel"`
CleanAfter bool `json:"cleanAfter"`
Provides bool `json:"provides"`
Expand Down Expand Up @@ -132,7 +134,6 @@ func MakeConfig() *Configuration {
Devel: false,
MakepkgBin: "makepkg",
MakepkgConf: "",
NoConfirm: false,
PacmanBin: "pacman",
PGPFetch: true,
PacmanConf: "/etc/pacman.conf",
Expand Down
2 changes: 1 addition & 1 deletion pkg/settings/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func handleConfig(config *Configuration, option, value string) bool {
case "searchby":
config.SearchBy = value
case "noconfirm":
config.NoConfirm = true
NoConfirm = true
case "config":
config.PacmanConf = value
case "redownload":
Expand Down

0 comments on commit 7b70462

Please sign in to comment.