internal/exportdata/export.go   A
last analyzed

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 17
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A exportdata.NewExport 0 9 3
1
package exportdata
2
3
import (
4
	"adrianolaselva.github.io/csvql/pkg/exportdata"
5
	"adrianolaselva.github.io/csvql/pkg/exportdata/csv"
6
	"adrianolaselva.github.io/csvql/pkg/exportdata/jsonl"
7
	"database/sql"
8
	"fmt"
9
	"github.com/schollz/progressbar/v3"
10
)
11
12
const (
13
	CSVLineExportType  = "csv"
14
	JSONLineExportType = "jsonl"
15
)
16
17
func NewExport(exportType string, rows *sql.Rows, exportPath string, bar *progressbar.ProgressBar) (exportdata.Export, error) {
18
	switch exportType {
19
	case CSVLineExportType:
20
		return csv.NewCsvExport(rows, exportPath, bar), nil
21
	case JSONLineExportType:
22
		return jsonl.NewJsonlExport(rows, exportPath, bar), nil
23
	}
24
25
	return nil, fmt.Errorf("export type %s not defined", exportType)
26
}
27