sq/cli/cmd_drivers.go
Neil O'Toole 58ccfc9ded
Json driver; refactoring of core packages (#66)
* Type Detector refactor

* json driver impl; refactoring of source.Files reader et al

* working on kind detector

* significant switcheroo of packages

* partway throught refactoring Kind

* major package switcheroo for Kind
2020-08-23 04:42:15 -06:00

31 lines
804 B
Go

package cli
import (
"github.com/spf13/cobra"
"github.com/neilotoole/sq/libsq/core/errz"
)
func newDriversCmd() (*cobra.Command, runFunc) {
cmd := &cobra.Command{
Use: "drivers",
Short: "List available drivers",
}
cmd.Flags().BoolP(flagJSON, flagJSONShort, false, flagJSONUsage)
cmd.Flags().BoolP(flagTable, flagTableShort, false, flagTableUsage)
cmd.Flags().BoolP(flagHeader, flagHeaderShort, false, flagHeaderUsage)
cmd.Flags().BoolP(flagMonochrome, flagMonochromeShort, false, flagMonochromeUsage)
return cmd, execDrivers
}
func execDrivers(rc *RunContext, cmd *cobra.Command, args []string) error {
if len(args) > 0 {
return errz.Errorf("invalid arguments: zero arguments expected")
}
drvrs := rc.registry.DriversMetadata()
return rc.writers.metaw.DriverMetadata(drvrs)
}