commit cc4a670b442a5cfe635e7cc22b300e6dcb1db17f
parent 1b7ccb533859eb7916d8d15cb68f013cec546842
Author: Sean Enck <sean@ttypty.com>
Date: Sat, 15 Oct 2022 10:48:16 -0400
return results from usage
Diffstat:
2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/cmd/main.go b/cmd/main.go
@@ -52,7 +52,7 @@ func main() {
func processInfoCommands(command string, args []string) (bool, error) {
switch command {
case cli.HelpCommand:
- cli.Usage()
+ fmt.Println(strings.Join(cli.Usage(), "\n"))
case cli.VersionCommand:
fmt.Printf("version: %s\n", strings.TrimSpace(version))
case cli.EnvCommand:
diff --git a/internal/cli/core.go b/internal/cli/core.go
@@ -59,26 +59,27 @@ func commandText(args, name, desc string) string {
if len(args) > 0 {
arguments = fmt.Sprintf("[%s]", args)
}
- return fmt.Sprintf(" %-15s %-10s %s\n", name, arguments, desc)
+ return fmt.Sprintf(" %-15s %-10s %s", name, arguments, desc)
}
// Usage return usage information
func Usage() []string {
- fmt.Println("lb usage:")
- printCommand(ClipCommand, "entry", "copy the entry's value into the clipboard")
- printCommand(EnvCommand, "", "display environment variable information")
- printCommand(FindCommand, "criteria", "perform a simplistic text search over the entry keys")
- printCommand(HelpCommand, "", "show this usage information")
- printCommand(InsertCommand, "entry", "insert a new entry into the store")
- printSubCommand(InsertCommand, InsertMultiCommand, "entry", "insert a multi-line entry")
- printCommand(ListCommand, "", "list entries")
- printCommand(MoveCommand, "src dst", "move an entry from one location to another with the store")
- printCommand(RemoveCommand, "entry", "remove an entry from the store")
- printCommand(ShowCommand, "entry", "show the entry's value")
- printCommand(TOTPCommand, "entry", "display an updating totp generated code")
- printSubCommand(TOTPCommand, TOTPClipCommand, "entry", "copy totp code to clipboard")
- printSubCommand(TOTPCommand, TOTPListCommand, "", "list entries with totp settings")
- printSubCommand(TOTPCommand, TOTPOnceCommand, "entry", "display the first generated code")
- printSubCommand(TOTPCommand, TOTPShortCommand, "entry", "display the first generated code with no details")
- printCommand(VersionCommand, "", "display version information")
+ results := []string{"lb usage"}
+ results = append(results, command(ClipCommand, "entry", "copy the entry's value into the clipboard"))
+ results = append(results, command(EnvCommand, "", "display environment variable information"))
+ results = append(results, command(FindCommand, "criteria", "perform a simplistic text search over the entry keys"))
+ results = append(results, command(HelpCommand, "", "show this usage information"))
+ results = append(results, command(InsertCommand, "entry", "insert a new entry into the store"))
+ results = append(results, subCommand(InsertCommand, InsertMultiCommand, "entry", "insert a multi-line entry"))
+ results = append(results, command(ListCommand, "", "list entries"))
+ results = append(results, command(MoveCommand, "src dst", "move an entry from one location to another with the store"))
+ results = append(results, command(RemoveCommand, "entry", "remove an entry from the store"))
+ results = append(results, command(ShowCommand, "entry", "show the entry's value"))
+ results = append(results, command(TOTPCommand, "entry", "display an updating totp generated code"))
+ results = append(results, subCommand(TOTPCommand, TOTPClipCommand, "entry", "copy totp code to clipboard"))
+ results = append(results, subCommand(TOTPCommand, TOTPListCommand, "", "list entries with totp settings"))
+ results = append(results, subCommand(TOTPCommand, TOTPOnceCommand, "entry", "display the first generated code"))
+ results = append(results, subCommand(TOTPCommand, TOTPShortCommand, "entry", "display the first generated code with no details"))
+ results = append(results, command(VersionCommand, "", "display version information"))
+ return results
}