mirror of
https://github.com/rwxrob/bonzai
synced 2024-11-18 15:25:45 +00:00
Add caller to test Call Methods
This commit is contained in:
parent
add9829c5d
commit
3aa6c71e55
@ -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 -----------------------
|
||||
|
@ -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
|
||||
|
@ -1 +0,0 @@
|
||||
|
Loading…
Reference in New Issue
Block a user