package input

import (
	"fmt"

	"github.com/johnkerl/miller/v6/pkg/cli"
)

func Create(readerOptions *cli.TReaderOptions, recordsPerBatch int64) (IRecordReader, error) {
	switch readerOptions.InputFileFormat {
	case "csv":
		return NewRecordReaderCSV(readerOptions, recordsPerBatch)
	case "csvlite":
		return NewRecordReaderCSVLite(readerOptions, recordsPerBatch)
	case "dkvp":
		return NewRecordReaderDKVP(readerOptions, recordsPerBatch)
	case "dkvpx":
		return NewRecordReaderDKVPX(readerOptions, recordsPerBatch)
	case "json":
		return NewRecordReaderJSON(readerOptions, recordsPerBatch)
	case "yaml":
		return NewRecordReaderYAML(readerOptions, recordsPerBatch)
	case "nidx":
		return NewRecordReaderNIDX(readerOptions, recordsPerBatch)
	case "md":
		return NewRecordReaderMarkdown(readerOptions, recordsPerBatch)
	case "markdown":
		return NewRecordReaderMarkdown(readerOptions, recordsPerBatch)
	case "pprint":
		return NewRecordReaderPPRINT(readerOptions, recordsPerBatch)
	case "tsv":
		return NewRecordReaderTSV(readerOptions, recordsPerBatch)
	case "xtab":
		return NewRecordReaderXTAB(readerOptions, recordsPerBatch)
	case "dcf":
		return NewRecordReaderDCF(readerOptions, recordsPerBatch)
	case "recutils":
		return NewRecordReaderREC(readerOptions, recordsPerBatch)
	case "gen":
		return NewPseudoReaderGen(readerOptions, recordsPerBatch)
	default:
		return nil, fmt.Errorf("input file format \"%s\" not found", readerOptions.InputFileFormat)
	}
}
