func callIn(in clif.Input, out clif.Output) { name := in.Ask("Who are you?", func(v string) error { if len(v) > 0 { return nil } else { return fmt.Errorf("Didn't catch that") } }) out.Printf("\n") father := "" for { father = in.Choose(fmt.Sprintf("Hello %s. Who is your father?", name), map[string]string{ "yoda": "The small, green guy", "darth": "The one with the dark cloark and a smokers voice", "obi": "The old man with the light thingy", }) if in.Confirm("You're sure about that? (y/n)") { break } else { out.Printf("\n") } } out.Printf("Well, <important>%s<reset>, ", name) if father != "darth" { out.Printf("<success>may the force be with you!<reset>\n") } else { out.Printf("<error>NOOOOOOOO!<reset>\n") } }
func callStyles(out clif.Output) { for token, _ := range clif.DefaultStyles { if token == "mine" { continue } out.Printf("Token \\<%s>: <%s>%s<reset>\n", token, token, token) } }
func callFoo(c *clif.Command, out clif.Output, custom1 exampleInterface, custom2 *exampleStruct) { out.Printf("Hello %s, how is the %s?\n", c.Argument("name").String(), c.Option("whatever").String()) if m := c.Argument("more-names").Strings(); m != nil && len(m) > 0 { for _, n := range m { out.Printf(" Say hello to <info>%s<reset>\n", n) } } if c.Option("counter").Int() > 5 { out.Printf(" You can count real high!\n") } out.Printf(" <headline>Custom 1: %s<reset>\n", custom1.Foo()) out.Printf(" <subline>Custom 2: %s<reset>\n", custom2.foo) }
func callMe(out clif.Output, in clif.Input, c *clif.Command, foo MyFoo, baz *MyBaz) { barIn := in.Ask("Gimme a bar integer: ", func(v string) error { _, err := strconv.Atoi(v) return err }) barInt, _ := strconv.Atoi(barIn) foo.SetBar(barInt) bazIn := in.AskRegex("Now please a baz: ", regexp.MustCompile(`^B`)) baz.baz = bazIn out.Printf("Bar: <info>%s<reset>\nBaz: <headline>%s<reset>\n", foo.Bar(), baz) }
func callHello(out clif.Output) { out.Printf("Hello <mine>World<reset>\n") }