Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/github.com/playwrigh…
Browse files Browse the repository at this point in the history
…t-community/playwright-go-0.3700.0
  • Loading branch information
mapkon authored Nov 3, 2023
2 parents fa48fa6 + 428c7d7 commit a0cf5cb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
2 changes: 2 additions & 0 deletions cmd/saml2aws/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/versent/saml2aws/v2/cmd/saml2aws/commands"
"github.com/versent/saml2aws/v2/pkg/flags"
"github.com/versent/saml2aws/v2/pkg/prompter"
)

var (
Expand Down Expand Up @@ -46,6 +47,7 @@ func buildCmdList(s kingpin.Settings) (target *[]string) {
func main() {

log.SetOutput(os.Stderr)
prompter.SetOutputWriter(os.Stderr)
log.SetFlags(0)
logrus.SetOutput(os.Stderr)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/alecthomas/kingpin v2.2.6+incompatible
github.com/avast/retry-go v3.0.0+incompatible
github.com/aws/aws-sdk-go v1.46.2
github.com/aws/aws-sdk-go v1.46.7
github.com/beevik/etree v1.2.0
github.com/danieljoos/wincred v1.2.0
github.com/google/uuid v1.3.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEq
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/aws/aws-sdk-go v1.46.2 h1:XZbOmjtN1VCfEtQq7QNFsbxIqO+bB+bRhiOBjp6AzWc=
github.com/aws/aws-sdk-go v1.46.2/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.46.7 h1:IjvAWeiJZlbETOemOwvheN5L17CvKvKW0T1xOC6d3Sc=
github.com/aws/aws-sdk-go v1.46.7/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/bearsh/hid v1.3.0 h1:GLNa8hvEzJxzQEEpheDUr2SivvH7iwTrJrDhFKutfX8=
github.com/bearsh/hid v1.3.0/go.mod h1:KbQByg8WfPr92v7aaKAHTtZUEVG7e2XRpcF8+TopQv8=
github.com/beevik/etree v1.2.0 h1:l7WETslUG/T+xOPs47dtd6jov2Ii/8/OjCldk5fYfQw=
Expand Down
27 changes: 21 additions & 6 deletions pkg/prompter/survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@ package prompter
import (
"errors"
"fmt"
"os"

survey "github.com/AlecAivazis/survey/v2"
survey_terminal "github.com/AlecAivazis/survey/v2/terminal"
)

// outputWriter is where for all prompts will be printed. Defaults to os.Stder.
var outputWriter survey_terminal.FileWriter = os.Stderr

// CliPrompter used to prompt for cli input
type CliPrompter struct {
}

// SetOutputWriter sets the output writer to use for all survey operations
func SetOutputWriter(writer survey_terminal.FileWriter) {
outputWriter = writer
}

// stdioOption returns the IO option to use for survey functions
func stdioOption() survey.AskOpt {
return survey.WithStdio(os.Stdin, outputWriter, os.Stderr)
}

// NewCli builds a new cli prompter
func NewCli() *CliPrompter {
return &CliPrompter{}
Expand All @@ -22,7 +37,7 @@ func (cli *CliPrompter) RequestSecurityCode(pattern string) string {
prompt := &survey.Input{
Message: fmt.Sprintf("Security Token [%s]", pattern),
}
_ = survey.AskOne(prompt, &token, survey.WithValidator(survey.Required))
_ = survey.AskOne(prompt, &token, survey.WithValidator(survey.Required), stdioOption())
return token
}

Expand All @@ -34,7 +49,7 @@ func (cli *CliPrompter) ChooseWithDefault(pr string, defaultValue string, option
Options: options,
Default: defaultValue,
}
_ = survey.AskOne(prompt, &selected, survey.WithValidator(survey.Required))
_ = survey.AskOne(prompt, &selected, survey.WithValidator(survey.Required), stdioOption())

// return the selected element index
for i, option := range options {
Expand All @@ -52,7 +67,7 @@ func (cli *CliPrompter) Choose(pr string, options []string) int {
Message: pr,
Options: options,
}
_ = survey.AskOne(prompt, &selected, survey.WithValidator(survey.Required))
_ = survey.AskOne(prompt, &selected, survey.WithValidator(survey.Required), stdioOption())

// return the selected element index
for i, option := range options {
Expand All @@ -70,7 +85,7 @@ func (cli *CliPrompter) String(pr string, defaultValue string) string {
Message: pr,
Default: defaultValue,
}
_ = survey.AskOne(prompt, &val)
_ = survey.AskOne(prompt, &val, stdioOption())
return val
}

Expand All @@ -80,7 +95,7 @@ func (cli *CliPrompter) StringRequired(pr string) string {
prompt := &survey.Input{
Message: pr,
}
_ = survey.AskOne(prompt, &val, survey.WithValidator(survey.Required))
_ = survey.AskOne(prompt, &val, survey.WithValidator(survey.Required), stdioOption())
return val
}

Expand All @@ -90,6 +105,6 @@ func (cli *CliPrompter) Password(pr string) string {
prompt := &survey.Password{
Message: pr,
}
_ = survey.AskOne(prompt, &val)
_ = survey.AskOne(prompt, &val, stdioOption())
return val
}

0 comments on commit a0cf5cb

Please sign in to comment.