func askOutputFormat()

in pkg/ecctl/init.go [432:451]


func askOutputFormat(cfg *Config, scanner *input.Scanner, writer, errWriter io.Writer) error {
	formatChoiceRaw := scanner.Scan(formatChoiceMsg)
	fmt.Fprintln(writer)
	formatChoice, err := strconv.Atoi(formatChoiceRaw)
	if err != nil {
		return err
	}

	cfg.Output = "text"
	switch formatChoice {
	case textFormatChoice:
	case jsonFormatChoice:
		cfg.Output = "json"
	default:
		fmt.Fprintln(errWriter, "invalid choice, defaulting to \"text\"")
	}

	fmt.Fprintln(writer)
	return nil
}