mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-20 06:31:32 +03:00
ed9aa38a67
* Expose source.Set.Data() method * jsonw.writeJSON cleaned up * sq add now respects --json * Location strings are subject to more scrutiny * Ignore .db files in project dir * sq add is more restrictive about location string * source.RedactedLocation now uses 'xxxxx' per stdlib url.URL.Redacted() * Update changelog for v0.23.0 * typos
37 lines
831 B
Go
37 lines
831 B
Go
package jsonw
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/neilotoole/sq/cli/buildinfo"
|
|
"github.com/neilotoole/sq/cli/output"
|
|
)
|
|
|
|
var _ output.VersionWriter = (*versionWriter)(nil)
|
|
|
|
// versionWriter implements output.VersionWriter for JSON.
|
|
type versionWriter struct {
|
|
out io.Writer
|
|
fm *output.Formatting
|
|
}
|
|
|
|
// NewVersionWriter returns a new output.VersionWriter instance
|
|
// that outputs version info in JSON.
|
|
func NewVersionWriter(out io.Writer, fm *output.Formatting) output.VersionWriter {
|
|
return &versionWriter{out: out, fm: fm}
|
|
}
|
|
|
|
func (w *versionWriter) Version(info buildinfo.BuildInfo, latestVersion string) error {
|
|
type cliBuildInfo struct {
|
|
buildinfo.BuildInfo
|
|
LatestVersion string `json:"latest_version"`
|
|
}
|
|
|
|
bi := cliBuildInfo{
|
|
BuildInfo: info,
|
|
LatestVersion: latestVersion,
|
|
}
|
|
|
|
return writeJSON(w.out, w.fm, bi)
|
|
}
|