From 3aa6c71e556c329bef08b870d7b140a76dcbb30a Mon Sep 17 00:00:00 2001 From: rwxrob Date: Thu, 24 Feb 2022 08:06:10 -0500 Subject: [PATCH] Add caller to test Call Methods --- bonzai.go | 8 ++++---- cmd_test.go | 8 ++++---- comp/standard | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 comp/standard diff --git a/bonzai.go b/bonzai.go index d6b8fa3..2e369ab 100644 --- a/bonzai.go +++ b/bonzai.go @@ -11,10 +11,10 @@ import ( ) // Method defines the main code to execute for a command (Cmd). By -// convention the parameter list should be names "args" if there are -// args expected and "none" if not. Methods must never write error -// output to anything but standard error and should almost always use -// the log package to do so. +// convention the parameter list should be named "args" if there are +// args expected and underscore (_) if not. Methods must never write +// error output to anything but standard error and should almost always +// use the log package to do so. type Method func(caller *Cmd, args ...string) error // ----------------------- errors, exit, debug ----------------------- diff --git a/cmd_test.go b/cmd_test.go index 5653d1f..c05ea99 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -15,7 +15,7 @@ func ExampleCmd_Seek() { hello := &bonzai.Cmd{ Name: `hello`, Params: []string{"there"}, - Call: func(args ...string) error { + Call: func(_ *bonzai.Cmd, args ...string) error { if len(args) > 0 { fmt.Printf("hello %v\n", args[0]) return nil @@ -28,7 +28,7 @@ func ExampleCmd_Seek() { hi := &bonzai.Cmd{ Name: `hi`, Params: []string{"there", "ya"}, - Call: func(args ...string) error { + Call: func(_ *bonzai.Cmd, args ...string) error { if len(args) > 0 { fmt.Printf("hi %v\n", args[0]) return nil @@ -40,7 +40,7 @@ func ExampleCmd_Seek() { yo := &bonzai.Cmd{ Name: `yo`, - Call: func(args ...string) error { + Call: func(_ *bonzai.Cmd, args ...string) error { fmt.Println("yo") return nil }, @@ -49,7 +49,7 @@ func ExampleCmd_Seek() { salut := &bonzai.Cmd{ Name: `salut`, Params: []string{"la"}, - Call: func(args ...string) error { + Call: func(_ *bonzai.Cmd, args ...string) error { if len(args) > 0 { fmt.Printf("salut %v\n", args[0]) return nil diff --git a/comp/standard b/comp/standard deleted file mode 100644 index 8b13789..0000000 --- a/comp/standard +++ /dev/null @@ -1 +0,0 @@ -