package repl

/*
import (
	"fmt"
	"strconv"
	"strings"
	"time"

	"github.com/spf13/cobra"
	clitypes "gitlink.org.cn/cloudream/jcs-pub/client/types"
)

func init() {
	var useID bool
	cmd := cobra.Command{
		Use:   "load",
		Short: "Load data from CDS to a storage service",
		Args:  cobra.ExactArgs(3),
		Run: func(cmd *cobra.Command, args []string) {
			cmdCtx := GetCmdCtx(cmd)

			if useID {
				pkgID, err := strconv.ParseInt(args[0], 10, 64)
				if err != nil {
					fmt.Printf("Invalid package ID: %s\n", args[0])
				}

				userSpaceID, err := strconv.ParseInt(args[1], 10, 64)
				if err != nil {
					fmt.Printf("Invalid user space ID: %s\n", args[1])
				}

				loadByID(cmdCtx, clitypes.PackageID(pkgID), clitypes.UserSpaceID(userSpaceID), args[2])
			} else {
				loadByPath(cmdCtx, args[0], args[1], args[2])
			}
		},
	}
	cmd.Flags().BoolVarP(&useID, "id", "i", false, "Use ID for both package and storage service instead of their name or path")
	RootCmd.AddCommand(&cmd)
}

func loadByPath(cmdCtx *CommandContext, pkgPath string, stgName string, rootPath string) {
	comps := strings.Split(strings.Trim(pkgPath, clitypes.ObjectPathSeparator), clitypes.ObjectPathSeparator)
	if len(comps) != 2 {
		fmt.Printf("Package path must be in format of <bucket>/<package>")
		return
	}

	pkg, err := cmdCtx.Cmdline.Svc.PackageSvc().GetByFullName(comps[0], comps[1])
	if err != nil {
		fmt.Println(err)
		return
	}

	// stg, err := cmdCtx.Cmdline.Svc.StorageSvc().GetByName(stgName)
	if err != nil {
		fmt.Println(err)
		return
	}

	loadByID(cmdCtx, pkg.PackageID, stg.StorageID, rootPath)
}

func loadByID(cmdCtx *CommandContext, pkgID clitypes.PackageID, stgID clitypes.StorageID, rootPath string) {
	startTime := time.Now()

	err := cmdCtx.Cmdline.Svc.StorageSvc().LoadPackage(pkgID, stgID, rootPath)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Printf("Package loaded to: %v:%v in %v\n", stgID, rootPath, time.Since(startTime))
}
*/
