|
|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
package command
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"bufio"
|
|
|
|
|
"flag"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io"
|
|
|
|
|
"math/rand"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
@ -137,6 +139,19 @@ func (m *Meta) flagSet(n string) *flag.FlagSet {
|
|
|
|
|
f.Var((*FlagVarFile)(&m.autoVariables), m.autoKey, "variable file")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create an io.Writer that writes to our Ui properly for errors.
|
|
|
|
|
// This is kind of a hack, but it does the job. Basically: create
|
|
|
|
|
// a pipe, use a scanner to break it into lines, and output each line
|
|
|
|
|
// to the UI. Do this forever.
|
|
|
|
|
errR, errW := io.Pipe()
|
|
|
|
|
errScanner := bufio.NewScanner(errR)
|
|
|
|
|
go func() {
|
|
|
|
|
for errScanner.Scan() {
|
|
|
|
|
m.Ui.Error(errScanner.Text())
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
f.SetOutput(errW)
|
|
|
|
|
|
|
|
|
|
return f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|