package commands

import (
	"fmt"

	"github.com/spf13/cobra"
)

func init() {
	listServicesCmd.Flags().BoolP("all", "a", false, "include internal service names")
}

var listServicesCmd = &cobra.Command{
	Use:   "list-services",
	Short: "print the service names in the localdev environment",
	RunE: func(cmd *cobra.Command, args []string) error {
		showInternal, err := cmd.Flags().GetBool("all")
		if err != nil {
			return err
		}
		services, err := listServices(cmd, showInternal)
		if err != nil {
			return err
		}
		for _, name := range services {
			fmt.Fprintln(cmd.OutOrStdout(), name)
		}
		return nil
	},
}
