added basic plugin structure
This commit is contained in:
40
cmd/char/ls.go
Normal file
40
cmd/char/ls.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package char
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/char/pkg/register"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewLsCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "ls",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
ctx := cmd.Context()
|
||||
|
||||
r, err := register.
|
||||
NewPluginRegisterBuilder().
|
||||
Add("gocli", "").
|
||||
Build(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
about, err := r.About(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for plugin, aboutText := range about {
|
||||
fmt.Printf("plugin: %s\n", plugin)
|
||||
fmt.Printf("\tabout: %s\n", aboutText)
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
15
cmd/char/root.go
Normal file
15
cmd/char/root.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package char
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
func NewCharCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "char",
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
NewLsCommand(),
|
||||
)
|
||||
|
||||
return cmd
|
||||
}
|
Reference in New Issue
Block a user