Create function for asking yes or no questions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
eaf49a4594
commit
4e71a5c35c
18
build.go
18
build.go
@ -174,14 +174,11 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st
|
||||
}
|
||||
|
||||
if !archMatches(vars.Architectures) {
|
||||
var buildAnyway bool
|
||||
survey.AskOne(
|
||||
&survey.Confirm{
|
||||
Message: "Your system's CPU architecture doesn't match this package. Do you want to build anyway?",
|
||||
Default: true,
|
||||
},
|
||||
&buildAnyway,
|
||||
)
|
||||
buildAnyway, err := yesNoPrompt("Your system's CPU architecture doesn't match this package. Do you want to build anyway?", true)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if !buildAnyway {
|
||||
os.Exit(1)
|
||||
}
|
||||
@ -455,10 +452,7 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st
|
||||
}
|
||||
|
||||
if len(buildDeps) > 0 {
|
||||
var removeBuildDeps bool
|
||||
err = survey.AskOne(&survey.Confirm{
|
||||
Message: "Would you like to remove build dependencies?",
|
||||
}, &removeBuildDeps)
|
||||
removeBuildDeps, err := yesNoPrompt("Would you like to remove build dependencies?", false)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
12
cli.go
12
cli.go
@ -29,3 +29,15 @@ func pkgPrompt(options []db.Package, verb string) ([]db.Package, error) {
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func yesNoPrompt(msg string, def bool) (bool, error) {
|
||||
var answer bool
|
||||
err := survey.AskOne(
|
||||
&survey.Confirm{
|
||||
Message: msg,
|
||||
Default: def,
|
||||
},
|
||||
&answer,
|
||||
)
|
||||
return answer, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user