2021-02-22 10:37:00 +03:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2023-11-20 04:06:36 +03:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2023-04-19 08:28:09 +03:00
|
|
|
"github.com/neilotoole/sq/cli/flag"
|
2023-05-19 17:24:18 +03:00
|
|
|
"github.com/neilotoole/sq/cli/run"
|
2021-02-22 10:37:00 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func newDriverCmd() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "driver",
|
2023-05-05 17:32:50 +03:00
|
|
|
Short: "Manage drivers",
|
|
|
|
Long: "Manage drivers.",
|
2021-02-22 10:37:00 +03:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
return cmd.Help()
|
|
|
|
},
|
|
|
|
|
|
|
|
Example: ` # List drivers
|
2023-03-12 07:21:05 +03:00
|
|
|
$ sq driver ls`,
|
2021-02-22 10:37:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func newDriverListCmd() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "ls",
|
2023-05-05 17:32:50 +03:00
|
|
|
Short: "List installed drivers",
|
|
|
|
Long: "List installed drivers.",
|
2023-04-19 08:28:09 +03:00
|
|
|
Args: cobra.NoArgs,
|
2021-02-22 10:37:00 +03:00
|
|
|
RunE: execDriverList,
|
|
|
|
}
|
|
|
|
|
2023-11-21 00:42:38 +03:00
|
|
|
addTextFormatFlags(cmd)
|
2023-04-19 08:28:09 +03:00
|
|
|
cmd.Flags().BoolP(flag.JSON, flag.JSONShort, false, flag.JSONUsage)
|
|
|
|
cmd.Flags().BoolP(flag.YAML, flag.YAMLShort, false, flag.YAMLUsage)
|
2023-05-05 20:41:22 +03:00
|
|
|
cmd.Flags().BoolP(flag.Compact, flag.CompactShort, false, flag.CompactUsage)
|
2021-02-22 10:37:00 +03:00
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2023-04-01 11:38:32 +03:00
|
|
|
func execDriverList(cmd *cobra.Command, _ []string) error {
|
2023-05-19 17:24:18 +03:00
|
|
|
ru := run.FromContext(cmd.Context())
|
|
|
|
drvrs := ru.DriverRegistry.DriversMetadata()
|
|
|
|
return ru.Writers.Metadata.DriverMetadata(drvrs)
|
2021-02-22 10:37:00 +03:00
|
|
|
}
|