Add caller to test Call Methods

This commit is contained in:
rwxrob 2022-02-24 08:06:10 -05:00
parent add9829c5d
commit 3aa6c71e55
No known key found for this signature in database
GPG Key ID: 2B9111F33082AE77
3 changed files with 8 additions and 9 deletions

View File

@ -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 -----------------------

View File

@ -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

View File

@ -1 +0,0 @@