File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,9 @@ type Command struct {
5858// simple way to get exec function
5959func (cmd * Command ) getExec () func (ctx context.Context , args []string ) error {
6060 switch {
61+ case cmd .Do != nil :
62+ cmd .ExecFunc = cmd .Do
63+ fallthrough
6164 case cmd .ExecFunc != nil :
6265 return cmd .ExecFunc
6366 case cmd .Exec != nil :
Original file line number Diff line number Diff line change @@ -354,6 +354,28 @@ func TestCommand_IsHidden(t *testing.T) {
354354 }
355355}
356356
357+ func TestDoShouldWork (t * testing.T ) {
358+ var ok bool
359+
360+ cmds := []Command {
361+ {
362+ Name : "foo" ,
363+ Do : func (ctx context.Context , args []string ) error {
364+ ok = true
365+ return nil
366+ },
367+ },
368+ }
369+
370+ r := RunnerOf (cmds , Config {
371+ Args : []string {"./someapp" , "foo" },
372+ AppName : "myapp" ,
373+ })
374+
375+ failIfErr (t , r .Run ())
376+ mustEqual (t , ok , true )
377+ }
378+
357379func TestExit (t * testing.T ) {
358380 wantStatus := 42
359381 wantOutput := "myapp: code 42\n "
You can’t perform that action at this time.
0 commit comments