2021-02-22 10:37:00 +03:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newDriverCmd() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "driver",
|
|
|
|
Short: "List or manage drivers",
|
|
|
|
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-03-12 06:25:19 +03:00
|
|
|
Short: "List available drivers.",
|
2021-02-22 10:37:00 +03:00
|
|
|
Args: cobra.ExactArgs(0),
|
|
|
|
RunE: execDriverList,
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.Flags().BoolP(flagJSON, flagJSONShort, false, flagJSONUsage)
|
|
|
|
cmd.Flags().BoolP(flagTable, flagTableShort, false, flagTableUsage)
|
|
|
|
cmd.Flags().BoolP(flagHeader, flagHeaderShort, false, flagHeaderUsage)
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func execDriverList(cmd *cobra.Command, args []string) error {
|
|
|
|
rc := RunContextFrom(cmd.Context())
|
|
|
|
drvrs := rc.registry.DriversMetadata()
|
|
|
|
return rc.writers.metaw.DriverMetadata(drvrs)
|
|
|
|
}
|