mirror of
https://gitea.com/gitea/tea.git
synced 2024-11-24 03:21:36 +01:00
added unified output
Signed-off-by: Andreas Ulm <andreas.ulm@root360.de>
This commit is contained in:
parent
16ba6125e4
commit
9edc039cd8
@ -92,7 +92,7 @@ func runIssuesList(ctx *cli.Context) error {
|
|||||||
var values [][]string
|
var values [][]string
|
||||||
|
|
||||||
if len(issues) == 0 {
|
if len(issues) == 0 {
|
||||||
Output(output, headers, values)
|
Output(outputValue, headers, values)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ func runIssuesList(ctx *cli.Context) error {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Output(output, headers, values)
|
Output(outputValue, headers, values)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,6 @@ import (
|
|||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
var output string
|
|
||||||
|
|
||||||
// CmdPulls represents to login a gitea server.
|
// CmdPulls represents to login a gitea server.
|
||||||
var CmdPulls = cli.Command{
|
var CmdPulls = cli.Command{
|
||||||
Name: "pulls",
|
Name: "pulls",
|
||||||
@ -46,7 +44,7 @@ func runPulls(ctx *cli.Context) error {
|
|||||||
var values [][]string
|
var values [][]string
|
||||||
|
|
||||||
if len(prs) == 0 {
|
if len(prs) == 0 {
|
||||||
Output(output, headers, values)
|
Output(outputValue, headers, values)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +66,7 @@ func runPulls(ctx *cli.Context) error {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Output(output, headers, values)
|
Output(outputValue, headers, values)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func runReleases(ctx *cli.Context) error {
|
|||||||
var values [][]string
|
var values [][]string
|
||||||
|
|
||||||
if len(releases) == 0 {
|
if len(releases) == 0 {
|
||||||
Output(output, headers, values)
|
Output(outputValue, headers, values)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ func runReleases(ctx *cli.Context) error {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Output(output, headers, values)
|
Output(outputValue, headers, values)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
65
cmd/repos.go
65
cmd/repos.go
@ -23,12 +23,7 @@ var CmdRepos = cli.Command{
|
|||||||
CmdReposList,
|
CmdReposList,
|
||||||
CmdReposFork,
|
CmdReposFork,
|
||||||
},
|
},
|
||||||
Flags: []cli.Flag{
|
Flags: append([]cli.Flag{}, DefaultFlags...),
|
||||||
cli.StringFlag{
|
|
||||||
Name: "login, l",
|
|
||||||
Usage: "Indicate one login, optional when inside a gitea repository",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CmdReposList represents a sub command of issues to list issues
|
// CmdReposList represents a sub command of issues to list issues
|
||||||
@ -37,11 +32,7 @@ var CmdReposList = cli.Command{
|
|||||||
Usage: "List available repositories",
|
Usage: "List available repositories",
|
||||||
Description: `List available repositories`,
|
Description: `List available repositories`,
|
||||||
Action: runReposList,
|
Action: runReposList,
|
||||||
Flags: []cli.Flag{
|
Flags: append([]cli.Flag{
|
||||||
cli.StringFlag{
|
|
||||||
Name: "login, l",
|
|
||||||
Usage: "Indicate one login, optional when inside a gitea repository",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "mode",
|
Name: "mode",
|
||||||
Usage: "Indicate one login, optional when inside a gitea repository",
|
Usage: "Indicate one login, optional when inside a gitea repository",
|
||||||
@ -54,12 +45,12 @@ var CmdReposList = cli.Command{
|
|||||||
Name: "user",
|
Name: "user",
|
||||||
Usage: "Indicate one login, optional when inside a gitea repository",
|
Usage: "Indicate one login, optional when inside a gitea repository",
|
||||||
},
|
},
|
||||||
},
|
}, DefaultFlags...),
|
||||||
}
|
}
|
||||||
|
|
||||||
// runReposList list repositories
|
// runReposList list repositories
|
||||||
func runReposList(ctx *cli.Context) error {
|
func runReposList(ctx *cli.Context) error {
|
||||||
login := initCommandLoginOnly(ctx)
|
login := initCommandLoginOnly()
|
||||||
|
|
||||||
mode := ctx.String("mode")
|
mode := ctx.String("mode")
|
||||||
org := ctx.String("org")
|
org := ctx.String("org")
|
||||||
@ -105,12 +96,19 @@ func runReposList(ctx *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rps) == 0 {
|
headers := []string{
|
||||||
fmt.Println("No repositories found")
|
string("Name"),
|
||||||
return nil
|
string("Type/Mode"),
|
||||||
|
string("SSH-URL"),
|
||||||
|
string("Owner"),
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Name | Type/Mode | SSH-URL | Owner")
|
var values [][]string
|
||||||
|
|
||||||
|
if len(rps) == 0 {
|
||||||
|
Output(outputValue, headers, values)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
for _, rp := range repos {
|
for _, rp := range repos {
|
||||||
var mode = "source"
|
var mode = "source"
|
||||||
if rp.Fork {
|
if rp.Fork {
|
||||||
@ -119,8 +117,17 @@ func runReposList(ctx *cli.Context) error {
|
|||||||
if rp.Mirror {
|
if rp.Mirror {
|
||||||
mode = "mirror"
|
mode = "mirror"
|
||||||
}
|
}
|
||||||
fmt.Printf("%s | %s | %s | %s\n", rp.FullName, mode, rp.SSHURL, rp.Owner.UserName)
|
values = append(
|
||||||
|
values,
|
||||||
|
[]string{
|
||||||
|
rp.FullName,
|
||||||
|
mode,
|
||||||
|
rp.SSHURL,
|
||||||
|
rp.Owner.UserName,
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
Output(outputValue, headers, values)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -131,24 +138,16 @@ var CmdReposFork = cli.Command{
|
|||||||
Usage: "fork repository",
|
Usage: "fork repository",
|
||||||
Description: `fork repository`,
|
Description: `fork repository`,
|
||||||
Action: runReposFork,
|
Action: runReposFork,
|
||||||
Flags: []cli.Flag{
|
Flags: append([]cli.Flag{
|
||||||
cli.StringFlag{
|
|
||||||
Name: "login, l",
|
|
||||||
Usage: "Indicate one login, optional when inside a gitea repository",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "repo, r",
|
|
||||||
Usage: "Indicate one repo, optional when inside a gitea repository",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "org",
|
Name: "org",
|
||||||
Usage: "Organization to fork the repository for (optional, default = logged in user)",
|
Usage: "Organization to fork the repository for (optional, default = logged in user)",
|
||||||
},
|
},
|
||||||
},
|
}, RepoDefaultFlags...),
|
||||||
}
|
}
|
||||||
|
|
||||||
func runReposFork(ctx *cli.Context) error {
|
func runReposFork(ctx *cli.Context) error {
|
||||||
login, owner, repo := initCommand(ctx)
|
login, owner, repo := initCommand()
|
||||||
forkOptions := gitea.CreateForkOption{}
|
forkOptions := gitea.CreateForkOption{}
|
||||||
if org := ctx.String("org"); org != "" {
|
if org := ctx.String("org"); org != "" {
|
||||||
forkOptions = gitea.CreateForkOption{
|
forkOptions = gitea.CreateForkOption{
|
||||||
@ -169,22 +168,22 @@ func runReposFork(ctx *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initCommandLoginOnly(ctx *cli.Context) *Login {
|
func initCommandLoginOnly() *Login {
|
||||||
err := loadConfig(yamlConfigPath)
|
err := loadConfig(yamlConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("load config file failed", yamlConfigPath)
|
log.Fatal("load config file failed", yamlConfigPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
var login *Login
|
var login *Login
|
||||||
if loginFlag := getGlobalFlag(ctx, "login"); loginFlag == "" {
|
if loginValue == "" {
|
||||||
login, err = getActiveLogin()
|
login, err = getActiveLogin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
login = getLoginByName(loginFlag)
|
login = getLoginByName(loginValue)
|
||||||
if login == nil {
|
if login == nil {
|
||||||
log.Fatal("indicated login name", loginFlag, "does not exist")
|
log.Fatal("indicated login name ", loginValue, " does not exist")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return login
|
return login
|
||||||
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -2,6 +2,10 @@
|
|||||||
code.gitea.io/sdk/gitea
|
code.gitea.io/sdk/gitea
|
||||||
# github.com/go-gitea/yaml v0.0.0-20170812160011-eb3733d160e7
|
# github.com/go-gitea/yaml v0.0.0-20170812160011-eb3733d160e7
|
||||||
github.com/go-gitea/yaml
|
github.com/go-gitea/yaml
|
||||||
|
# github.com/mattn/go-runewidth v0.0.4
|
||||||
|
github.com/mattn/go-runewidth
|
||||||
|
# github.com/olekukonko/tablewriter v0.0.1
|
||||||
|
github.com/olekukonko/tablewriter
|
||||||
# github.com/src-d/gcfg v1.4.0
|
# github.com/src-d/gcfg v1.4.0
|
||||||
github.com/src-d/gcfg
|
github.com/src-d/gcfg
|
||||||
github.com/src-d/gcfg/scanner
|
github.com/src-d/gcfg/scanner
|
||||||
|
Loading…
Reference in New Issue
Block a user