added basic plugin structure

This commit is contained in:
2022-11-01 14:26:54 +01:00
commit a693cbad37
18 changed files with 481 additions and 0 deletions

40
cmd/char/ls.go Normal file
View 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
View 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
}