cockroach: Index | Files

package cli

import ""


Package Files

bash_complete.go check.go cli.go csv_server.go format.go run.go run_unix.go

func AddSubCmd Uses

func AddSubCmd(fn func(userFacing bool) *cobra.Command)

AddSubCmd adds a sub-command closure to the workload cli.

Most commands are global singletons and hooked together in init functions but the workload ones do fancy things with making each generator in `workload.Registered` into a subcommand. This means the commands need to be generated after `workload.Registered` is fully populated, but the latter is now sometimes done in the outermost possible place (main.go) and so its init runs last. Instead, we return a closure that is called in the main function, which is guaranteed to run after all inits.

func CmdHelper Uses

func CmdHelper(
    gen workload.Generator, fn func(gen workload.Generator, urls []string, dbName string) error,
) func(*cobra.Command, []string)

CmdHelper handles common workload command logic, such as error handling and ensuring the database name in the connection string (if provided) matches the expected one.

func HandleErrs Uses

func HandleErrs(
    f func(cmd *cobra.Command, args []string) error,
) func(cmd *cobra.Command, args []string)

HandleErrs wraps a `RunE` cobra function to print an error but not the usage.

func SetCmdDefaults Uses

func SetCmdDefaults(cmd *cobra.Command) *cobra.Command

SetCmdDefaults ensures that the provided Cobra command will properly report an error if the user specifies an invalid subcommand. It is safe to call on any Cobra command.

This is a wontfix bug in Cobra:

func WorkloadCmd Uses

func WorkloadCmd(userFacing bool) *cobra.Command

WorkloadCmd returns a new command that can serve as the root of the workload command tree.

Package cli imports 29 packages (graph) and is imported by 16 packages. Updated 2020-08-05. Refresh now. Tools for package owners.