mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 13:41:49 +03:00
fabc46c758
* Switched more flags over to options mechanism * flag.IngestHeader * flag.CSVEmptyAsNull and flag.CSVDelim * flag.PingTimeout * more flags * flag.LogEnabled * logging flags
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/neilotoole/sq/cli/flag"
|
|
"github.com/neilotoole/sq/cli/run"
|
|
)
|
|
|
|
func newDriverCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "driver",
|
|
Short: "Manage drivers",
|
|
Long: "Manage drivers.",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return cmd.Help()
|
|
},
|
|
|
|
Example: ` # List drivers
|
|
$ sq driver ls`,
|
|
}
|
|
|
|
return cmd
|
|
}
|
|
|
|
func newDriverListCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "ls",
|
|
Short: "List installed drivers",
|
|
Long: "List installed drivers.",
|
|
Args: cobra.NoArgs,
|
|
RunE: execDriverList,
|
|
}
|
|
|
|
addTextFormatFlags(cmd)
|
|
cmd.Flags().BoolP(flag.JSON, flag.JSONShort, false, flag.JSONUsage)
|
|
cmd.Flags().BoolP(flag.YAML, flag.YAMLShort, false, flag.YAMLUsage)
|
|
addOptionFlag(cmd.Flags(), OptCompact)
|
|
|
|
return cmd
|
|
}
|
|
|
|
func execDriverList(cmd *cobra.Command, _ []string) error {
|
|
ru := run.FromContext(cmd.Context())
|
|
drvrs := ru.DriverRegistry.DriversMetadata()
|
|
return ru.Writers.Metadata.DriverMetadata(drvrs)
|
|
}
|