MCPcopy
hub / github.com/hashicorp/packer / FlagSet

Method FlagSet

command/meta.go:64–81  ·  view source on GitHub ↗

FlagSet returns a FlagSet with Packer SDK Ui support built-in

(n string)

Source from the content-addressed store, hash-verified

62
63// FlagSet returns a FlagSet with Packer SDK Ui support built-in
64func (m *Meta) FlagSet(n string) *flag.FlagSet {
65 f := flag.NewFlagSet(n, flag.ContinueOnError)
66
67 // Create an io.Writer that writes to our Ui properly for errors.
68 // This is kind of a hack, but it does the job. Basically: create
69 // a pipe, use a scanner to break it into lines, and output each line
70 // to the UI. Do this forever.
71 errR, errW := io.Pipe()
72 errScanner := bufio.NewScanner(errR)
73 go func() {
74 for errScanner.Scan() {
75 m.Ui.Error(errScanner.Text())
76 }
77 }()
78 f.SetOutput(errW)
79
80 return f
81}
82
83// ValidateFlags should be called after parsing flags to validate the
84// given flags

Callers 11

ParseArgsMethod · 0.80
ParseArgsMethod · 0.80
ParseArgsMethod · 0.80
ParseArgsMethod · 0.80
ParseArgsMethod · 0.80
ParseArgsMethod · 0.80
ParseArgsMethod · 0.80
ParseArgsMethod · 0.80
ParseArgsMethod · 0.80
ParseArgsMethod · 0.80
ParseArgsMethod · 0.80

Calls 1

ErrorMethod · 0.65

Tested by

no test coverage detected