mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
stdout/stderr around
A lot of functions in the cmd and ctl packages were passing these
around and barely using them. Replaced them with a logger for most
functions. Some functions get an io.Writer instead so that their
tests can find the output they're looking for.
More cleanup on fb-1766: reworked the tests that were using io.Pipe
or os.Pipe to check their results so they now use a bytes.Buffer.
Unexported some variables that didn't need to be exported.
Fixed NewConfigCommand to use the provided stderr, not os.Stderr.
Added tests for rbf_dump, rbf_page, and keygen, since those weren't
being tested at all.
Added chksum_test, final cleanup.
(cherry picked from commit f627199acb)
40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
// Copyright 2022 Molecula Corp. (DBA FeatureBase).
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
package cmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/molecula/featurebase/v3/ctl"
|
|
"github.com/molecula/featurebase/v3/logger"
|
|
)
|
|
|
|
var Exporter *ctl.ExportCommand
|
|
|
|
func newExportCommand(logdest logger.Logger) *cobra.Command {
|
|
Exporter = ctl.NewExportCommand(logdest)
|
|
exportCmd := &cobra.Command{
|
|
Use: "export",
|
|
Short: "Export data from FeatureBase.",
|
|
Long: `
|
|
Bulk exports a fragment to a CSV file. If the OUTFILE is not specified then
|
|
the output is written to STDOUT.
|
|
|
|
The format of the CSV file is:
|
|
|
|
ROWID,COLUMNID
|
|
|
|
The file does not contain any headers.
|
|
`,
|
|
RunE: usageErrorWrapper(Exporter),
|
|
}
|
|
flags := exportCmd.Flags()
|
|
|
|
flags.StringVarP(&Exporter.Host, "host", "", "localhost:10101", "host:port of FeatureBase.")
|
|
flags.StringVarP(&Exporter.Index, "index", "i", "", "FeatureBase index to export")
|
|
flags.StringVarP(&Exporter.Field, "field", "f", "", "Field to export")
|
|
flags.StringVarP(&Exporter.Path, "output-file", "o", "", "File to write export to - default stdout")
|
|
ctl.SetTLSConfig(flags, "", &Exporter.TLS.CertificatePath, &Exporter.TLS.CertificateKeyPath, &Exporter.TLS.CACertPath, &Exporter.TLS.SkipVerify, &Exporter.TLS.EnableClientVerification)
|
|
|
|
return exportCmd
|
|
}
|