1
0
mirror of https://github.com/rancher/os.git synced 2025-04-28 03:20:50 +00:00

Re-add input from stdin

This commit is contained in:
Jason-ZW 2019-02-27 13:56:15 +08:00 committed by niusmallnan
parent bfd9baa280
commit 67ee26adda

View File

@ -289,11 +289,17 @@ func validate(c *cli.Context) error {
}
func inputBytes(c *cli.Context) ([]byte, error) {
input := os.Stdin
inputFile := c.String("input")
if inputFile == "" {
return nil, errors.New("input parameter can not be empty")
if inputFile != "" {
var err error
input, err = os.Open(inputFile)
if err != nil {
return nil, err
}
defer input.Close()
}
content, err := ioutil.ReadFile(inputFile)
content, err := ioutil.ReadAll(input)
if err != nil {
return nil, err
}