2021-02-22 10:37:00 +03:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2023-04-19 08:28:09 +03:00
|
|
|
"github.com/neilotoole/sq/cli/flag"
|
2021-02-22 10:37:00 +03:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
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-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 {
|
2021-02-22 10:37:00 +03:00
|
|
|
rc := RunContextFrom(cmd.Context())
|
2023-04-26 18:16:42 +03:00
|
|
|
drvrs := rc.driverReg.DriversMetadata()
|
2021-02-22 10:37:00 +03:00
|
|
|
return rc.writers.metaw.DriverMetadata(drvrs)
|
|
|
|
}
|