add tea times command #54

Merged
lunny merged 20 commits from noerw/tea:50-cmd-times into master 2020-03-06 03:43:34 +00:00
7 changed files with 58 additions and 39 deletions
Showing only changes of commit d889f61a68 - Show all commits

View File

@ -21,28 +21,32 @@ var (
// LoginFlag provides flag to specify tea login profile
var LoginFlag = cli.StringFlag{
Name: "login, l",
Name: "login",
Aliases: []string{"l"},
Usage: "Use a different Gitea login. Optional",
Destination: &loginValue,
}
// RepoFlag provides flag to specify repository
var RepoFlag = cli.StringFlag{
Name: "repo, r",
Name: "repo",
Aliases: []string{"r"},
Usage: "Repository to interact with. Optional",
Destination: &repoValue,
}
// RemoteFlag provides flag to specify remote repository
var RemoteFlag = cli.StringFlag{
Name: "remote, R",
Name: "remote",
Aliases: []string{"R"},
Usage: "Discover Gitea login from remote. Optional",
Destination: &remoteValue,
}
// OutputFlag provides flag to specify output type
var OutputFlag = cli.StringFlag{
Name: "output, o",
Name: "output",
Aliases: []string{"o"},
Usage: "Output format. (csv, simple, table, tsv, yaml)",
Destination: &outputValue,
}

View File

@ -125,12 +125,14 @@ var CmdIssuesCreate = cli.Command{
Action: runIssuesCreate,
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "title, t",
Usage: "issue title to create",
Name: "title",
Aliases: []string{"t"},
Usage: "issue title to create",
},
&cli.StringFlag{
Name: "body, b",
Usage: "issue body to create",
Name: "body",
Aliases: []string{"b"},
Usage: "issue body to create",
},
}, LoginRepoFlags...),
}

View File

@ -30,8 +30,9 @@ var CmdLabels = cli.Command{
},
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "save, s",
Usage: "Save all the labels as a file",
Name: "save, s",
Outdated
Review

can you remove the s there?

can you remove the `s` there?
Review

done

done
Aliases: []string{"s"},
Usage: "Save all the labels as a file",
},
}, AllDefaultFlags...),
}

View File

@ -34,24 +34,28 @@ var cmdLoginAdd = cli.Command{
Description: `Add a Gitea login`,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name, n",
Usage: "Login name",
Name: "name",
Aliases: []string{"n"},
Usage: "Login name",
},
&cli.StringFlag{
Name: "url, u",
Name: "url",
Aliases: []string{"u"},
Value: "https://try.gitea.io",
EnvVars: []string{"GITEA_SERVER_URL"},
Usage: "Server URL",
},
&cli.StringFlag{
Name: "token, t",
Name: "token",
Aliases: []string{"t"},
Value: "",
EnvVars: []string{"GITEA_SERVER_TOKEN"},
Usage: "Access token. Can be obtained from Settings > Applications",
},
&cli.BoolFlag{
Name: "insecure, i",
Usage: "Disable TLS verification",
Name: "insecure",
Aliases: []string{"i"},
Usage: "Disable TLS verification",
},
},
Action: runLoginAdd,

View File

@ -20,8 +20,9 @@ var CmdLogout = cli.Command{
Action: runLogout,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name, n",
Usage: "Login name to remove",
Name: "name",
Aliases: []string{"n"},
Usage: "Login name to remove",
},
},
}

View File

@ -80,24 +80,29 @@ var CmdReleaseCreate = cli.Command{
Usage: "Target refs, branch name or commit id",
},
&cli.StringFlag{
Name: "title, t",
Usage: "Release title",
Name: "title",
Aliases: []string{"t"},
Usage: "Release title",
},
&cli.StringFlag{
Name: "note, n",
Usage: "Release notes",
Name: "note",
Aliases: []string{"n"},
Usage: "Release notes",
},
&cli.BoolFlag{
Name: "draft, d",
Usage: "Is a draft",
Name: "draft",
Aliases: []string{"d"},
Usage: "Is a draft",
},
&cli.BoolFlag{
Name: "prerelease, p",
Usage: "Is a pre-release",
Name: "prerelease",
Aliases: []string{"p"},
Usage: "Is a pre-release",
},
&cli.StringSliceFlag{
Name: "asset, a",
Usage: "List of files to attach",
Name: "asset",
Aliases: []string{"a"},
Usage: "List of files to attach",
},
}, LoginRepoFlags...),
}

View File

@ -14,7 +14,7 @@ import (
"code.gitea.io/sdk/gitea"
"github.com/araddon/dateparse"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)
// CmdTrackedTimes represents the command to operate repositories' times.
@ -24,21 +24,23 @@ var CmdTrackedTimes = cli.Command{
Description: `Operate on tracked times of the repository's issues`,
ArgsUsage: "[username | #issue]",
Action: runTrackedTimes,
Subcommands: []cli.Command{
CmdTrackedTimesAdd,
Subcommands: []*cli.Command{
&CmdTrackedTimesAdd,
},
Flags: append([]cli.Flag{
// TODO: add --from --to filters on t.Created
cli.StringFlag{
Name: "from, f",
&cli.StringFlag{
Name: "from",
Aliases: []string{"f"},
Usage: "Show only times tracked after this date",
},
cli.StringFlag{
Name: "until, u",
&cli.StringFlag{
Name: "until",
Aliases: []string{"u"},
Usage: "Show only times tracked before this date",
},
cli.BoolFlag{
Name: "total, t",
&cli.BoolFlag{
Name: "total",
Aliases: []string{"t"},
Usage: "Print the total duration at the end",
},
}, AllDefaultFlags...),
@ -147,7 +149,7 @@ var CmdTrackedTimesAdd = cli.Command{
func runTrackedTimesAdd(ctx *cli.Context) error {
login, owner, repo := initCommand()
if len(ctx.Args()) < 2 {
if ctx.Args().Len() < 2 {
return fmt.Errorf("No issue or duration specified.\nUsage:\t%s", ctx.Command.UsageText)
}