Skip to content

Commit

Permalink
remove context.Context from Run func (entry point)
Browse files Browse the repository at this point in the history
  • Loading branch information
koron committed Mar 14, 2024
1 parent 7be29ce commit 242dd44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions subcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func (s Set) Run(ctx context.Context, args []string) error {
}

// Run runs a Runner with ctx and args.
func Run(ctx context.Context, r Runner, args ...string) error {
return r.Run(ctx, args)
func Run(r Runner, args ...string) error {
return r.Run(context.Background(), args)
}

var keyNames = struct{}{}
Expand Down
10 changes: 5 additions & 5 deletions subcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestCommand(t *testing.T) {
called = true
return nil
})
err := subcmd.Run(context.Background(), cmd)
err := subcmd.Run(cmd)
if err != nil {
t.Fatal(err)
}
Expand All @@ -25,7 +25,7 @@ func TestCommand(t *testing.T) {

func TestCommandNil(t *testing.T) {
cmd := subcmd.DefineCommand("foo", t.Name(), nil)
err := subcmd.Run(context.Background(), cmd)
err := subcmd.Run(cmd)
if err == nil {
t.Fatal("unexpected succeed")
}
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestSet(t *testing.T) {
[]string{"-id", "ABC"},
},
} {
err := subcmd.Run(context.Background(), set, c.args...)
err := subcmd.Run(set, c.args...)
if err != nil {
t.Fatalf("failed for case#%d (%+v): %s", i, c, err)
continue
Expand Down Expand Up @@ -136,7 +136,7 @@ Available sub-commands are:
delete delete an entry
item operate items`},
} {
err := subcmd.Run(context.Background(), rootSet, c.args...)
err := subcmd.Run(rootSet, c.args...)
if err == nil {
t.Fatalf("unexpected succeed at #%d %+v", i, c)
}
Expand All @@ -152,7 +152,7 @@ func TestAutoWidth(t *testing.T) {
subcmd.DefineCommand("verylongname", "long name command", nil),
subcmd.DefineCommand("short", "short name command", nil),
)
err := subcmd.Run(context.Background(), rootSet)
err := subcmd.Run(rootSet)
if err == nil {
t.Fatal("unexpected succeed")
}
Expand Down

0 comments on commit 242dd44

Please sign in to comment.