diff --git a/cmd/enbas/main.go b/cmd/enbas/main.go index 1dcbd40..d4aa348 100644 --- a/cmd/enbas/main.go +++ b/cmd/enbas/main.go @@ -4,8 +4,6 @@ import ( "flag" "fmt" "os" - "slices" - "strings" "codeflow.dananglin.me.uk/apollo/enbas/internal/executor" ) @@ -46,7 +44,7 @@ func run() error { commandLogin: "login to an account on GoToSocial", commandVersion: "print the application's version and build information", commandShow: "print details about a specified resource", - commandSwitch: "switch to a different account", + commandSwitch: "perform a switch operation (e.g. switch logged in accounts)", commandCreate: "create a specific resource", commandDelete: "delete a specific resource", commandEdit: "edit a specific resource", @@ -178,41 +176,3 @@ func run() error { return nil } - -func usageFunc(summaries map[string]string) func() { - cmds := make([]string, len(summaries)) - ind := 0 - - for k := range summaries { - cmds[ind] = k - ind++ - } - - slices.Sort(cmds) - - return func() { - var builder strings.Builder - - builder.WriteString("SUMMARY:\n enbas - A GoToSocial client for the terminal.\n\n") - - if binaryVersion != "" { - builder.WriteString("VERSION:\n " + binaryVersion + "\n\n") - } - - builder.WriteString("USAGE:\n enbas [flags]\n enbas [command]\n\nCOMMANDS:") - - for _, cmd := range cmds { - fmt.Fprintf(&builder, "\n %s\t%s", cmd, summaries[cmd]) - } - - builder.WriteString("\n\nFLAGS:\n --help\n print the help message\n") - flag.VisitAll(func(f *flag.Flag) { - fmt.Fprintf(&builder, "\n --%s\n %s\n", f.Name, f.Usage) - }) - - builder.WriteString("\nUse \"enbas [command] --help\" for more information about a command.\n") - - w := flag.CommandLine.Output() - fmt.Fprint(w, builder.String()) - } -} diff --git a/cmd/enbas/usage.go b/cmd/enbas/usage.go new file mode 100644 index 0000000..1aaea70 --- /dev/null +++ b/cmd/enbas/usage.go @@ -0,0 +1,46 @@ +package main + +import ( + "flag" + "fmt" + "slices" + "strings" +) + +func usageFunc(summaries map[string]string) func() { + cmds := make([]string, len(summaries)) + ind := 0 + + for k := range summaries { + cmds[ind] = k + ind++ + } + + slices.Sort(cmds) + + return func() { + var builder strings.Builder + + builder.WriteString("SUMMARY:\n enbas - A GoToSocial client for the terminal.\n\n") + + if binaryVersion != "" { + builder.WriteString("VERSION:\n " + binaryVersion + "\n\n") + } + + builder.WriteString("USAGE:\n enbas [flags]\n enbas [command]\n\nCOMMANDS:") + + for _, cmd := range cmds { + fmt.Fprintf(&builder, "\n %s\t%s", cmd, summaries[cmd]) + } + + builder.WriteString("\n\nFLAGS:\n --help\n print the help message\n") + flag.VisitAll(func(f *flag.Flag) { + fmt.Fprintf(&builder, "\n --%s\n %s\n", f.Name, f.Usage) + }) + + builder.WriteString("\nUse \"enbas [command] --help\" for more information about a command.\n") + + w := flag.CommandLine.Output() + fmt.Fprint(w, builder.String()) + } +}