mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-20 06:31:32 +03:00
81f631e135
* Renamed source.Type to source.DriverType for clarity * More renaming wrt source.DriverType * Renamed output.Formatting to output.Printing
47 lines
936 B
Go
47 lines
936 B
Go
package jsonw
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/neilotoole/sq/cli/config"
|
|
|
|
"github.com/neilotoole/sq/cli/output"
|
|
)
|
|
|
|
var _ output.ConfigWriter = (*configWriter)(nil)
|
|
|
|
// configWriter implements output.ConfigWriter.
|
|
type configWriter struct {
|
|
out io.Writer
|
|
pr *output.Printing
|
|
}
|
|
|
|
// NewConfigWriter returns a new output.ConfigWriter.
|
|
func NewConfigWriter(out io.Writer, pr *output.Printing) output.ConfigWriter {
|
|
return &configWriter{out: out, pr: pr}
|
|
}
|
|
|
|
// Location implements output.ConfigWriter.
|
|
func (w *configWriter) Location(loc, origin string) error {
|
|
type cfgInfo struct {
|
|
Location string `json:"location"`
|
|
Origin string `json:"origin,omitempty"`
|
|
}
|
|
|
|
c := cfgInfo{
|
|
Location: loc,
|
|
Origin: origin,
|
|
}
|
|
|
|
return writeJSON(w.out, w.pr, c)
|
|
}
|
|
|
|
// Options implements output.ConfigWriter.
|
|
func (w *configWriter) Options(opts *config.Options) error {
|
|
if opts == nil {
|
|
return nil
|
|
}
|
|
|
|
return writeJSON(w.out, w.pr, opts)
|
|
}
|