Add the ability to list helper commands
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2023-10-10 12:59:43 -07:00
parent 5d49de6fde
commit 3b382b9747
1 changed files with 27 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"os"
"strings"
@ -14,8 +15,10 @@ import (
)
var helperCmd = &cli.Command{
Name: "helper",
Usage: "Run a lure helper command",
Name: "helper",
Usage: "Run a lure helper command",
ArgsUsage: `<helper_name|"list">`,
Subcommands: []*cli.Command{helperListCmd},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "dest-dir",
@ -28,6 +31,10 @@ var helperCmd = &cli.Command{
ctx := c.Context
log := loggerctx.From(ctx)
if c.Args().Len() < 1 {
cli.ShowSubcommandHelpAndExit(c, 1)
}
wd, err := os.Getwd()
if err != nil {
log.Fatal("Error getting working directory").Err(err).Send()
@ -58,4 +65,22 @@ var helperCmd = &cli.Command{
return helper(hc, c.Args().First(), c.Args().Slice()[1:])
},
CustomHelpTemplate: cli.CommandHelpTemplate,
BashComplete: func(ctx *cli.Context) {
for name := range helpers.Helpers {
fmt.Println(name)
}
},
}
var helperListCmd = &cli.Command{
Name: "list",
Usage: "List all the available helper commands",
Aliases: []string{"ls"},
Action: func(ctx *cli.Context) error {
for name := range helpers.Helpers {
fmt.Println(name)
}
return nil
},
}