diff --git a/main.go b/main.go index 92d22dd..fe6a1de 100644 --- a/main.go +++ b/main.go @@ -2,8 +2,12 @@ package main import ( "flag" + "fmt" "log" + "os" + "sort" "strconv" + "strings" "github.com/schachmat/ingo" _ "github.com/schachmat/wego/backends" @@ -11,6 +15,23 @@ import ( "github.com/schachmat/wego/iface" ) +func pluginLists() { + bEnds := make([]string, 0, len(iface.AllBackends)) + for name := range iface.AllBackends { + bEnds = append(bEnds, name) + } + sort.Strings(bEnds) + + fEnds := make([]string, 0, len(iface.AllFrontends)) + for name := range iface.AllFrontends { + fEnds = append(fEnds, name) + } + sort.Strings(fEnds) + + fmt.Fprintln(os.Stderr, "Available backends:", strings.Join(bEnds, ", ")) + fmt.Fprintln(os.Stderr, "Available frontends:", strings.Join(fEnds, ", ")) +} + func main() { // initialize backends and frontends (flags and default config) for _, be := range iface.AllBackends { @@ -32,6 +53,13 @@ func main() { selectedFrontend := flag.String("frontend", "ascii-art-table", "`FRONTEND` to be used") flag.StringVar(selectedFrontend, "f", "ascii-art-table", "`FRONTEND` to be used (shorthand)") + // print out a list of all backends and frontends in the usage + tmpUsage := flag.Usage + flag.Usage = func() { + tmpUsage() + pluginLists() + } + // read/write config and parse flags if err := ingo.Parse("wego"); err != nil { log.Fatalf("Error parsing config: %v", err)