github.com/wawandco/oxplugins@v0.7.11/tools/cli/help/toplevel.go (about) 1 package help 2 3 import ( 4 "fmt" 5 "os" 6 "text/tabwriter" 7 8 "github.com/wawandco/oxplugins/plugins" 9 ) 10 11 // printTopLevel prints the top level help text with a table that contains top level 12 // commands (names) and descriptions. 13 func (h *Command) printTopLevel() { 14 fmt.Printf("Oxpecker allows to build apps with ease\n\n") 15 fmt.Println("Usage:") 16 fmt.Printf(" ox [command]\n\n") 17 18 w := new(tabwriter.Writer) 19 defer w.Flush() 20 21 // minwidth, tabwidth, padding, padchar, flags 22 w.Init(os.Stdout, 8, 8, 3, '\t', 0) 23 fmt.Println("Commands:") 24 25 for _, plugin := range h.commands { 26 helpText := "" 27 if ht, ok := plugin.(plugins.HelpTexter); ok { 28 helpText = ht.HelpText() 29 } 30 31 fmt.Fprintf(w, " %v\t%v\n", plugin.Name(), helpText) 32 } 33 34 }