mirror of
https://github.com/Jguer/yay
synced 2024-08-31 21:58:39 +00:00
chore(menus): refactor editDiff menus
This commit is contained in:
parent
d096d15973
commit
49577191c6
|
@ -133,10 +133,6 @@ func gitUpdateSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, path, nam
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func diffNumberMenu(bases []dep.Base, installed stringset.StringSet, noConfirm bool, defaultAnswer string) ([]dep.Base, error) {
|
|
||||||
return editDiffNumberMenu(bases, installed, true, noConfirm, defaultAnswer)
|
|
||||||
}
|
|
||||||
|
|
||||||
func updatePkgbuildSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, buildDir string, bases []dep.Base) error {
|
func updatePkgbuildSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, buildDir string, bases []dep.Base) error {
|
||||||
var errMulti multierror.MultiError
|
var errMulti multierror.MultiError
|
||||||
|
|
||||||
|
@ -160,7 +156,7 @@ func Diff(ctx context.Context, cmdBuilder exe.ICmdBuilder,
|
||||||
|
|
||||||
pkgbuildNumberMenu(buildDir, bases, installed)
|
pkgbuildNumberMenu(buildDir, bases, installed)
|
||||||
|
|
||||||
toDiff, errMenu := diffNumberMenu(bases, installed, noConfirm, diffDefaultAnswer)
|
toDiff, errMenu := editDiffNumberMenu(bases, installed, gotext.Get("Diffs to show?"), noConfirm, diffDefaultAnswer)
|
||||||
if errMenu != nil || len(toDiff) == 0 {
|
if errMenu != nil || len(toDiff) == 0 {
|
||||||
return errMenu
|
return errMenu
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,6 @@ func editor(editorConfig, editorFlags string, noConfirm bool) (editor string, ar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func editNumberMenu(bases []dep.Base, installed stringset.StringSet, noConfirm bool, defaultAnswer string) ([]dep.Base, error) {
|
|
||||||
return editDiffNumberMenu(bases, installed, false, noConfirm, defaultAnswer)
|
|
||||||
}
|
|
||||||
|
|
||||||
func editPkgbuilds(buildDir string, bases []dep.Base, editorConfig,
|
func editPkgbuilds(buildDir string, bases []dep.Base, editorConfig,
|
||||||
editorFlags string, srcinfos map[string]*gosrc.Srcinfo, noConfirm bool) error {
|
editorFlags string, srcinfos map[string]*gosrc.Srcinfo, noConfirm bool) error {
|
||||||
pkgbuilds := make([]string, 0, len(bases))
|
pkgbuilds := make([]string, 0, len(bases))
|
||||||
|
@ -125,7 +121,7 @@ func Edit(editMenuOption bool, buildDir string, bases []dep.Base, editorConfig,
|
||||||
|
|
||||||
pkgbuildNumberMenu(buildDir, bases, installed)
|
pkgbuildNumberMenu(buildDir, bases, installed)
|
||||||
|
|
||||||
toEdit, errMenu := editNumberMenu(bases, installed, noConfirm, editDefaultAnswer)
|
toEdit, errMenu := editDiffNumberMenu(bases, installed, gotext.Get("PKGBUILDs to edit?"), noConfirm, editDefaultAnswer)
|
||||||
if errMenu != nil || len(toEdit) == 0 {
|
if errMenu != nil || len(toEdit) == 0 {
|
||||||
return errMenu
|
return errMenu
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,28 +38,16 @@ func pkgbuildNumberMenu(buildDir string, bases []dep.Base, installed stringset.S
|
||||||
fmt.Print(toPrint)
|
fmt.Print(toPrint)
|
||||||
}
|
}
|
||||||
|
|
||||||
func editDiffNumberMenu(bases []dep.Base, installed stringset.StringSet, diff, noConfirm bool, defaultAnswer string) ([]dep.Base, error) {
|
func editDiffNumberMenu(bases []dep.Base, installed stringset.StringSet,
|
||||||
var (
|
message string, noConfirm bool, defaultAnswer string) ([]dep.Base, error) {
|
||||||
toEdit = make([]dep.Base, 0)
|
toEdit := make([]dep.Base, 0)
|
||||||
editInput string
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
if diff {
|
text.Infoln(message)
|
||||||
text.Infoln(gotext.Get("Diffs to show?"))
|
text.Infoln(gotext.Get("%s [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)", text.Cyan(gotext.Get("[N]one"))))
|
||||||
text.Infoln(gotext.Get("%s [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)", text.Cyan(gotext.Get("[N]one"))))
|
|
||||||
|
|
||||||
editInput, err = text.GetInput(defaultAnswer, noConfirm)
|
editInput, err := text.GetInput(defaultAnswer, noConfirm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
|
||||||
} else {
|
|
||||||
text.Infoln(gotext.Get("PKGBUILDs to edit?"))
|
|
||||||
text.Infoln(gotext.Get("%s [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)", text.Cyan(gotext.Get("[N]one"))))
|
|
||||||
editInput, err = text.GetInput(defaultAnswer, noConfirm)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eInclude, eExclude, eOtherInclude, eOtherExclude := intrange.ParseNumberMenu(editInput)
|
eInclude, eExclude, eOtherInclude, eOtherExclude := intrange.ParseNumberMenu(editInput)
|
||||||
|
|
Loading…
Reference in a new issue