package main import ( "github.com/Masterminds/cookoo" "github.com/Masterminds/cookoo/cli" ) func main() { reg, router, cxt := cookoo.Cookoo() reg.Route("hello", "Say hello!", func(c cookoo.Context, params *cookoo.Params) (interface{}, cookoo.Interrupt) { name, err := params.MustString("name", "No name provided") if err != nil { return nil, &cookoo.FatalError{Err: err} } message := "Hello, " + name + "!" return message, nil }) err := router.HandleRequest("hello", cxt, false) if err != nil { cli.HandleExitCoder(err) } }
reg.Route("hello", "Say hello!", func(c cookoo.Context, params *cookoo.Params) (interface{}, cookoo.Interrupt) { name, _ := params.String("name", "Stranger") city, _ := params.String("city", "Somewhere") message := "Hello, " + name + "! Welcome to " + city + "!" return message, nil })This command uses the `String` method from the Params package to obtain default values for "name" and "city" if they are not provided. In summary, the Params package from github.com.masterminds.cookoo provides functionality for handling and parsing command-line arguments in Go.