| package commands |
| |
| import ( |
| "fmt" |
| |
| "v.io/v23" |
| "v.io/v23/context" |
| "v.io/x/lib/cmdline" |
| "v.io/x/ref/lib/v23cmd" |
| ) |
| |
| var Commands = []*cmdline.Command{ |
| &cmdline.Command{ |
| Name: "dump", |
| Short: "Print a dump of the database", |
| Long: `Print a dump of the database.`, |
| Runner: v23cmd.RunnerFuncWithInit(DumpDB, InitCtx), |
| }, |
| } |
| |
| var commandCtx *context.T |
| func SetCtx(ctx *context.T) { |
| commandCtx = ctx |
| } |
| |
| func InitCtx() (*context.T, v23.Shutdown, error) { |
| if commandCtx == nil { |
| return v23.TryInit() |
| } else { |
| return commandCtx, dummyShutdown, nil |
| } |
| } |
| |
| func dummyShutdown() {} |
| |
| func GetCommand(name string) (*cmdline.Command, error) { |
| for _, cmd := range Commands { |
| if cmd.Name == name { |
| return cmd, nil |
| } |
| } |
| |
| return nil, fmt.Errorf("no command %q", name) |
| } |