Add the ability to list helper commands
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
5d49de6fde
commit
3b382b9747
29
helper.go
29
helper.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -14,8 +15,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var helperCmd = &cli.Command{
|
var helperCmd = &cli.Command{
|
||||||
Name: "helper",
|
Name: "helper",
|
||||||
Usage: "Run a lure helper command",
|
Usage: "Run a lure helper command",
|
||||||
|
ArgsUsage: `<helper_name|"list">`,
|
||||||
|
Subcommands: []*cli.Command{helperListCmd},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "dest-dir",
|
Name: "dest-dir",
|
||||||
|
@ -28,6 +31,10 @@ var helperCmd = &cli.Command{
|
||||||
ctx := c.Context
|
ctx := c.Context
|
||||||
log := loggerctx.From(ctx)
|
log := loggerctx.From(ctx)
|
||||||
|
|
||||||
|
if c.Args().Len() < 1 {
|
||||||
|
cli.ShowSubcommandHelpAndExit(c, 1)
|
||||||
|
}
|
||||||
|
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error getting working directory").Err(err).Send()
|
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:])
|
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
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue