package cmd import ( "flag" "fmt" "strings" ) type Runner interface { Parse([]string) error Name() string Run() error } func SpruceUsage() { usage := `A tool for building CVs Usage: spruce [flags] spruce [command] Available Commands: create create a new CV JSON file generate generate a PDF file from an existing CV JSON file version print the application's build information Flags: -h, --help print the help message for spruce Use "spruce [command] --help" for more information about a command. ` fmt.Print(usage) } func usageFunc(name, summary string, flagset *flag.FlagSet) func() { return func() { var b strings.Builder w := flag.CommandLine.Output() fmt.Fprintf(&b, "%s\n\nUsage:\n spruce %s [flags]\n\nFlags:", summary, name) flagset.VisitAll(func(f *flag.Flag) { fmt.Fprintf(&b, "\n --%s\n %s\n", f.Name, f.Usage) }) fmt.Fprint(w, b.String()) } }