sq/cli/cmd_list.go
Neil O'Toole ed9aa38a67
Improvements to source commands (#139)
* 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
2022-12-31 20:17:44 -07:00

26 lines
550 B
Go

package cli
import (
"github.com/spf13/cobra"
)
func newSrcListCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "ls",
Short: "List data sources",
Long: "List data sources.",
Args: cobra.ExactArgs(0),
RunE: execSrcList,
}
cmd.Flags().BoolP(flagHeader, flagHeaderShort, false, flagHeaderUsage)
cmd.Flags().BoolP(flagJSON, flagJSONShort, false, flagJSONUsage)
return cmd
}
func execSrcList(cmd *cobra.Command, args []string) error {
rc := RunContextFrom(cmd.Context())
return rc.writers.srcw.SourceSet(rc.Config.Sources)
}