replace flag globals, require context for commands #291
|
@ -7,7 +7,7 @@ package cmd
|
|||
import (
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/cmd/issues"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
|
@ -39,8 +39,8 @@ func runIssues(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func runIssueDetail(cmd *cli.Context, index string) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
idx, err := utils.ArgToIndex(index)
|
||||
if err != nil {
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
|
@ -31,8 +31,8 @@ var CmdIssuesClose = cli.Command{
|
|||
|
||||
// editIssueState abstracts the arg parsing to edit the given issue
|
||||
func editIssueState(cmd *cli.Context, opts gitea.EditIssueOption) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
if ctx.Args().Len() == 0 {
|
||||
log.Fatal(ctx.Command.ArgsUsage)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -37,8 +37,8 @@ var CmdIssuesCreate = cli.Command{
|
|||
}
|
||||
|
||||
func runIssuesCreate(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
issue, _, err := ctx.Login.Client().CreateIssue(ctx.Owner, ctx.Repo, gitea.CreateIssueOption{
|
||||
Title: ctx.String("title"),
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -27,8 +27,8 @@ var CmdIssuesList = cli.Command{
|
|||
|
||||
// RunIssuesList list issues
|
||||
func RunIssuesList(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
state := gitea.StateOpen
|
||||
switch ctx.String("state") {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -43,8 +43,8 @@ var CmdLabelCreate = cli.Command{
|
|||
}
|
||||
|
||||
func runLabelCreate(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
labelFile := ctx.String("file")
|
||||
var err error
|
||||
|
|
|
@ -7,7 +7,7 @@ package labels
|
|||
import (
|
||||
"log"
|
||||
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
@ -27,8 +27,8 @@ var CmdLabelDelete = cli.Command{
|
|||
}
|
||||
|
||||
func runLabelDelete(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
_, err := ctx.Login.Client().DeleteLabel(ctx.Owner, ctx.Repo, ctx.Int64("id"))
|
||||
if err != nil {
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
"code.gitea.io/tea/modules/task"
|
||||
|
||||
|
@ -36,8 +36,8 @@ var CmdLabelsList = cli.Command{
|
|||
|
||||
// RunLabelsList list labels.
|
||||
func RunLabelsList(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
client := ctx.Login.Client()
|
||||
labels, _, err := client.ListRepoLabels(ctx.Owner, ctx.Repo, gitea.ListLabelsOptions{
|
||||
|
|
|
@ -7,7 +7,7 @@ package labels
|
|||
import (
|
||||
"log"
|
||||
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -40,8 +40,8 @@ var CmdLabelUpdate = cli.Command{
|
|||
}
|
||||
|
||||
func runLabelUpdate(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
id := ctx.Int64("id")
|
||||
var pName, pColor, pDescription *string
|
||||
|
|
|
@ -7,7 +7,7 @@ package cmd
|
|||
import (
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/cmd/milestones"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -40,8 +40,8 @@ func runMilestones(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func runMilestoneDetail(cmd *cli.Context, name string) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
milestone, _, err := client.GetMilestoneByName(ctx.Owner, ctx.Repo, name)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -42,8 +42,8 @@ var CmdMilestonesCreate = cli.Command{
|
|||
}
|
||||
|
||||
func runMilestonesCreate(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
title := ctx.String("title")
|
||||
if len(title) == 0 {
|
||||
|
|
|
@ -6,7 +6,7 @@ package milestones
|
|||
|
||||
import (
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
@ -23,8 +23,8 @@ var CmdMilestonesDelete = cli.Command{
|
|||
}
|
||||
|
||||
func deleteMilestone(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
_, err := client.DeleteMilestoneByName(ctx.Owner, ctx.Repo, ctx.Args().First())
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
|
@ -66,8 +66,8 @@ var CmdMilestoneRemoveIssue = cli.Command{
|
|||
}
|
||||
|
||||
func runMilestoneIssueList(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
state := gitea.StateOpen
|
||||
|
@ -110,8 +110,8 @@ func runMilestoneIssueList(cmd *cli.Context) error {
|
|||
}
|
||||
|
||||
func runMilestoneIssueAdd(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
if ctx.Args().Len() == 0 {
|
||||
return fmt.Errorf("need two arguments")
|
||||
|
@ -137,8 +137,8 @@ func runMilestoneIssueAdd(cmd *cli.Context) error {
|
|||
}
|
||||
|
||||
func runMilestoneIssueRemove(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
if ctx.Args().Len() == 0 {
|
||||
return fmt.Errorf("need two arguments")
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -35,8 +35,8 @@ var CmdMilestonesList = cli.Command{
|
|||
|
||||
// RunMilestonesList list milestones
|
||||
func RunMilestonesList(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
state := gitea.StateOpen
|
||||
switch ctx.String("state") {
|
||||
|
|
|
@ -6,7 +6,7 @@ package milestones
|
|||
|
||||
import (
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -26,8 +26,8 @@ var CmdMilestonesReopen = cli.Command{
|
|||
}
|
||||
|
||||
func editMilestoneStatus(cmd *cli.Context, close bool) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
state := gitea.StateOpen
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -47,7 +47,7 @@ func runNotifications(cmd *cli.Context) error {
|
|||
var news []*gitea.NotificationThread
|
||||
var err error
|
||||
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx := context.InitCommand(cmd)
|
||||
client := ctx.Login.Client()
|
||||
|
||||
listOpts := ctx.GetListOptions()
|
||||
|
@ -69,7 +69,7 @@ func runNotifications(cmd *cli.Context) error {
|
|||
Status: status,
|
||||
})
|
||||
} else {
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
news, _, err = client.ListRepoNotifications(ctx.Owner, ctx.Repo, gitea.ListNotificationOptions{
|
||||
ListOptions: listOpts,
|
||||
Status: status,
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
local_git "code.gitea.io/tea/modules/git"
|
||||
|
||||
"github.com/skratchdot/open-golang/open"
|
||||
|
@ -27,8 +27,8 @@ var CmdOpen = cli.Command{
|
|||
}
|
||||
|
||||
func runOpen(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
var suffix string
|
||||
number := ctx.Args().Get(0)
|
||||
|
|
|
@ -7,7 +7,7 @@ package organizations
|
|||
import (
|
||||
"log"
|
||||
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
@ -23,7 +23,7 @@ var CmdOrganizationDelete = cli.Command{
|
|||
|
||||
// RunOrganizationDelete delete user organization
|
||||
func RunOrganizationDelete(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx := context.InitCommand(cmd)
|
||||
|
||||
client := ctx.Login.Client()
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -30,7 +30,7 @@ var CmdOrganizationList = cli.Command{
|
|||
|
||||
// RunOrganizationList list user organizations
|
||||
func RunOrganizationList(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx := context.InitCommand(cmd)
|
||||
client := ctx.Login.Client()
|
||||
|
||||
userOrganizations, _, err := client.ListUserOrgs(ctx.Login.User, gitea.ListOrgsOptions{
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/cmd/pulls"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
|
@ -42,8 +42,8 @@ func runPulls(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func runPullDetail(cmd *cli.Context, index string) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
idx, err := utils.ArgToIndex(index)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/interact"
|
||||
"code.gitea.io/tea/modules/task"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
@ -27,8 +27,8 @@ var CmdPullsCheckout = cli.Command{
|
|||
}
|
||||
|
||||
func runPullsCheckout(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{LocalRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{LocalRepo: true})
|
||||
if ctx.Args().Len() != 1 {
|
||||
log.Fatal("Must specify a PR index")
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/interact"
|
||||
"code.gitea.io/tea/modules/task"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
@ -32,8 +32,8 @@ var CmdPullsClean = cli.Command{
|
|||
}
|
||||
|
||||
func runPullsClean(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{LocalRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{LocalRepo: true})
|
||||
if ctx.Args().Len() != 1 {
|
||||
return fmt.Errorf("Must specify a PR index")
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ package pulls
|
|||
|
||||
import (
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/interact"
|
||||
"code.gitea.io/tea/modules/task"
|
||||
|
||||
|
@ -43,8 +43,8 @@ var CmdPullsCreate = cli.Command{
|
|||
}
|
||||
|
||||
func runPullsCreate(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{LocalRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{LocalRepo: true})
|
||||
|
||||
// no args -> interactive mode
|
||||
if ctx.NumFlags() == 0 {
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -27,8 +27,8 @@ var CmdPullsList = cli.Command{
|
|||
|
||||
// RunPullsList return list of pulls
|
||||
func RunPullsList(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
state := gitea.StateOpen
|
||||
switch ctx.String("state") {
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -62,8 +62,8 @@ var CmdReleaseCreate = cli.Command{
|
|||
}
|
||||
|
||||
func runReleaseCreate(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
release, resp, err := ctx.Login.Client().CreateRelease(ctx.Owner, ctx.Repo, gitea.CreateReleaseOption{
|
||||
TagName: ctx.String("tag"),
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
@ -34,8 +34,8 @@ var CmdReleaseDelete = cli.Command{
|
|||
}
|
||||
|
||||
func runReleaseDelete(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
tag := ctx.Args().First()
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -57,8 +57,8 @@ var CmdReleaseEdit = cli.Command{
|
|||
}
|
||||
|
||||
func runReleaseEdit(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
tag := ctx.Args().First()
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -31,8 +31,8 @@ var CmdReleaseList = cli.Command{
|
|||
|
||||
// RunReleasesList list releases
|
||||
func RunReleasesList(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
releases, _, err := ctx.Login.Client().ListReleases(ctx.Owner, ctx.Repo, gitea.ListReleasesOptions{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
|
|
|
@ -6,7 +6,7 @@ package cmd
|
|||
|
||||
import (
|
||||
"code.gitea.io/tea/cmd/repos"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
|
@ -38,7 +38,7 @@ func runRepos(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func runRepoDetail(cmd *cli.Context, path string) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx := context.InitCommand(cmd)
|
||||
client := ctx.Login.Client()
|
||||
repoOwner, repoName := utils.GetOwnerAndRepo(path, ctx.Owner)
|
||||
repo, _, err := client.GetRepo(repoOwner, repoName)
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -83,7 +83,7 @@ var CmdRepoCreate = cli.Command{
|
|||
}
|
||||
|
||||
func runRepoCreate(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx := context.InitCommand(cmd)
|
||||
client := ctx.Login.Client()
|
||||
var (
|
||||
repo *gitea.Repository
|
||||
|
|
|
@ -6,7 +6,7 @@ package repos
|
|||
|
||||
import (
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -45,7 +45,7 @@ var CmdReposList = cli.Command{
|
|||
|
||||
// RunReposList list repositories
|
||||
func RunReposList(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx := context.InitCommand(cmd)
|
||||
client := ctx.Login.Client()
|
||||
|
||||
typeFilter, err := getTypeFilter(cmd)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -57,7 +57,7 @@ var CmdReposSearch = cli.Command{
|
|||
}
|
||||
|
||||
func runReposSearch(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx := context.InitCommand(cmd)
|
||||
client := ctx.Login.Client()
|
||||
|
||||
var ownerID int64
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
@ -32,8 +32,8 @@ var CmdTrackedTimesAdd = cli.Command{
|
|||
}
|
||||
|
||||
func runTrackedTimesAdd(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
if ctx.Args().Len() < 2 {
|
||||
return fmt.Errorf("No issue or duration specified.\nUsage:\t%s", ctx.Command.UsageText)
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -27,8 +27,8 @@ var CmdTrackedTimesDelete = cli.Command{
|
|||
}
|
||||
|
||||
func runTrackedTimesDelete(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
if ctx.Args().Len() < 2 {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
|
@ -51,8 +51,8 @@ var CmdTrackedTimesList = cli.Command{
|
|||
|
||||
// RunTimesList list repositories
|
||||
func RunTimesList(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
var times []*gitea.TrackedTime
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"log"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -26,8 +26,8 @@ var CmdTrackedTimesReset = cli.Command{
|
|||
}
|
||||
|
||||
func runTrackedTimesReset(cmd *cli.Context) error {
|
||||
ctx := config.InitCommand(cmd)
|
||||
ctx.Ensure(config.CtxRequirement{RemoteRepo: true})
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
if ctx.Args().Len() != 1 {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package config
|
||||
package context
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -12,6 +12,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/git"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
|
@ -22,7 +23,7 @@ import (
|
|||
// TeaContext contains all context derived during command initialization and wraps cli.Context
|
||||
type TeaContext struct {
|
||||
*cli.Context
|
||||
Login *Login
|
||||
Login *config.Login
|
||||
RepoSlug string // <owner>/<repo>
|
||||
Owner string // repo owner as derived from context
|
||||
Repo string // repo name as derived from context or provided in flag
|
||||
|
@ -102,12 +103,12 @@ func InitCommand(ctx *cli.Context) *TeaContext {
|
|||
|
||||
// override login from flag, or use default login if repo based detection failed
|
||||
if len(loginFlag) != 0 {
|
||||
login = GetLoginByName(loginFlag)
|
||||
login = config.GetLoginByName(loginFlag)
|
||||
if login == nil {
|
||||
log.Fatalf("Login name '%s' does not exist", loginFlag)
|
||||
}
|
||||
} else if login == nil {
|
||||
if login, err = GetDefaultLogin(); err != nil {
|
||||
if login, err = config.GetDefaultLogin(); err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +120,7 @@ func InitCommand(ctx *cli.Context) *TeaContext {
|
|||
}
|
||||
|
||||
// contextFromLocalRepo discovers login & repo slug from the default branch remote of the given local repo
|
||||
func contextFromLocalRepo(repoValue, remoteValue string) (*git.TeaRepo, *Login, string, error) {
|
||||
func contextFromLocalRepo(repoValue, remoteValue string) (*git.TeaRepo, *config.Login, string, error) {
|
||||
repo, err := git.RepoFromPath(repoValue)
|
||||
if err != nil {
|
||||
return nil, nil, "", err
|
||||
|
@ -155,7 +156,7 @@ func contextFromLocalRepo(repoValue, remoteValue string) (*git.TeaRepo, *Login,
|
|||
return repo, nil, "", fmt.Errorf("Remote '%s' not found in this Git repository", remoteValue)
|
||||
}
|
||||
|
||||
logins, err := GetLogins()
|
||||
logins, err := config.GetLogins()
|
||||
if err != nil {
|
||||
return repo, nil, "", err
|
||||
}
|
Loading…
Reference in New Issue
Block a user