package app import ( "context" "strconv" "cnb.cool/looc/git-cnb/cnb" "cnb.cool/looc/git-cnb/ui" "github.com/spf13/cobra" ) var InfoCmd = &cobra.Command{ Use: "info", Short: "print information of this repo", Long: "print information of this repo", Run: func(cmd *cobra.Command, args []string) { Info(cmd.Context()) }, } func Info(ctx context.Context) { user, err := cnb.Me(ctx, Client) if err != nil { ui.ErrorWithExit(err.Error()) } repo, err := cnb.GetRepo(ctx, Client, Repo) if err != nil { ui.ErrorWithExit(err.Error()) } kvs := []ui.KV{ {K: "MyID", V: user.ID}, {K: "MyUserName", V: user.UserName}, {K: "MyNickName", V: user.NickName}, {K: "MyEmail", V: user.UserEmail}, {K: "RepoName", V: repo.Path}, {K: "RepoID", V: strconv.FormatInt(repo.ID, 10)}, {K: "RepoLicense", V: repo.License}, {K: "RepoStars", V: strconv.FormatUint(uint64(repo.Stars), 10)}, {K: "RepoForks", V: strconv.FormatUint(uint64(repo.Forks), 10)}, {K: "RepoDescription", V: repo.Description}, } ui.KVTable(kvs) }