Skip to content
Snippets Groups Projects
xbus_actor_list.go 740 B
Newer Older
package cmd

import (
	"fmt"

	"github.com/jessevdk/go-flags"
)

func SetupXbusActorListCmd[E any](program *Program[E], cmd *flags.Command) *XbusActorListCmd[E] {
	serveCmd := XbusActorListCmd[E]{
		program: program,
	}

	_, err := cmd.AddCommand("actor-list", "List all the available actor services", "", &serveCmd)
	if err != nil {
		panic(err)
	}

	return &serveCmd
}

//nolint:lll
type XbusActorListCmd[E any] struct {
	program *Program[E]
}

func (cmd *XbusActorListCmd[E]) Execute([]string) error {

	fmt.Printf("The following actor services are provided by %s:\n", cmd.program.Name)
	for _, ff := range cmd.program.setupXbusActors {
		for _, factory := range ff(cmd.program) {
			fmt.Println("*", factory.Name)
		}
	}

	return nil
}