// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2025 STACKIT GmbH & Co. KG

package instance

import (
	"github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/create"
	"github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/delete"
	"github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/describe"
	"github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/list"
	"github.com/stackitcloud/stackit-cli/internal/cmd/beta/edge/instance/update"

	"github.com/stackitcloud/stackit-cli/internal/pkg/args"
	"github.com/stackitcloud/stackit-cli/internal/pkg/types"
	"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

	"github.com/spf13/cobra"
)

func NewCmd(params *types.CmdParams) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "instance",
		Short: "Provides functionality for edge instances.",
		Long:  "Provides functionality for STACKIT Edge Cloud (STEC) instance management.",
		Args:  args.NoArgs,
		Run:   utils.CmdHelp,
	}
	addSubcommands(cmd, params)
	return cmd
}

func addSubcommands(cmd *cobra.Command, params *types.CmdParams) {
	cmd.AddCommand(list.NewCmd(params))
	cmd.AddCommand(describe.NewCmd(params))
	cmd.AddCommand(create.NewCmd(params))
	cmd.AddCommand(update.NewCmd(params))
	cmd.AddCommand(delete.NewCmd(params))
}
