Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AllDefaultFlags = append([]cli.Flag{ &RepoFlag, &RemoteFlag, }, LoginOutputFlags...)
AllDefaultFlags defines flags that should be available for all subcommands working with dedicated repositories to work around issue and provide --login, --repo and --output: https://github.com/urfave/cli/issues/585
var CmdIssues = cli.Command{ Name: "issues", Usage: "List and create issues", Description: `List and create issues`, ArgsUsage: "[<issue index>]", Action: runIssues, Subcommands: []*cli.Command{ &CmdIssuesList, &CmdIssuesCreate, &CmdIssuesReopen, &CmdIssuesClose, }, Flags: AllDefaultFlags, }
CmdIssues represents to login a gitea server.
var CmdIssuesClose = cli.Command{ Name: "close", Usage: "Change state of an issue to 'closed'", Description: `Change state of an issue to 'closed'`, ArgsUsage: "<issue index>", Action: func(ctx *cli.Context) error { var s = gitea.StateClosed return editIssueState(ctx, gitea.EditIssueOption{State: &s}) }, Flags: AllDefaultFlags, }
CmdIssuesClose represents a sub command of issues to close an issue
var CmdIssuesCreate = cli.Command{ Name: "create", Usage: "Create an issue on repository", Description: `Create an issue on repository`, Action: runIssuesCreate, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "title", Aliases: []string{"t"}, Usage: "issue title to create", }, &cli.StringFlag{ Name: "body", Aliases: []string{"b"}, Usage: "issue body to create", }, }, LoginRepoFlags...), }
CmdIssuesCreate represents a sub command of issues to create issue
var CmdIssuesList = cli.Command{ Name: "ls", Usage: "List issues of the repository", Description: `List issues of the repository`, Action: runIssuesList, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "state", Usage: "Filter by issue state (all|open|closed)", DefaultText: "open", }, }, AllDefaultFlags...), }
CmdIssuesList represents a sub command of issues to list issues
var CmdIssuesReopen = cli.Command{ Name: "reopen", Aliases: []string{"open"}, Usage: "Change state of an issue to 'open'", Description: `Change state of an issue to 'open'`, ArgsUsage: "<issue index>", Action: func(ctx *cli.Context) error { var s = gitea.StateOpen return editIssueState(ctx, gitea.EditIssueOption{State: &s}) }, Flags: AllDefaultFlags, }
CmdIssuesReopen represents a sub command of issues to open an issue
var CmdLabelCreate = cli.Command{
Name: "create",
Usage: "Create a label",
Description: `Create a label`,
Action: runLabelCreate,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "label name",
},
&cli.StringFlag{
Name: "color",
Usage: "label color value",
},
&cli.StringFlag{
Name: "description",
Usage: "label description",
},
&cli.StringFlag{
Name: "file",
Usage: "indicate a label file",
},
},
}
CmdLabelCreate represents a sub command of labels to create label.
var CmdLabelDelete = cli.Command{
Name: "delete",
Usage: "Delete a label",
Description: `Delete a label`,
Action: runLabelCreate,
Flags: []cli.Flag{
&cli.IntFlag{
Name: "id",
Usage: "label id",
},
},
}
CmdLabelDelete represents a sub command of labels to delete label.
var CmdLabelUpdate = cli.Command{
Name: "update",
Usage: "Update a label",
Description: `Update a label`,
Action: runLabelUpdate,
Flags: []cli.Flag{
&cli.IntFlag{
Name: "id",
Usage: "label id",
},
&cli.StringFlag{
Name: "name",
Usage: "label name",
},
&cli.StringFlag{
Name: "color",
Usage: "label color value",
},
&cli.StringFlag{
Name: "description",
Usage: "label description",
},
},
}
CmdLabelUpdate represents a sub command of labels to update label.
var CmdLabels = cli.Command{ Name: "labels", Usage: "Manage issue labels", Description: `Manage issue labels`, Action: runLabels, Subcommands: []*cli.Command{ &CmdLabelCreate, &CmdLabelUpdate, &CmdLabelDelete, }, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "save", Aliases: []string{"s"}, Usage: "Save all the labels as a file", }, }, AllDefaultFlags...), }
CmdLabels represents to operate repositories' labels.
var CmdLogin = cli.Command{
Name: "login",
Usage: "Log in to a Gitea server",
Description: `Log in to a Gitea server`,
Action: runLoginList,
Subcommands: []*cli.Command{
&cmdLoginList,
&cmdLoginAdd,
},
}
CmdLogin represents to login a gitea server.
var CmdLogout = cli.Command{ Name: "logout", Usage: "Log out from a Gitea server", Description: `Log out from a Gitea server`, Action: runLogout, Flags: []cli.Flag{ &cli.StringFlag{ Name: "name", Aliases: []string{"n"}, Usage: "Login name to remove", }, }, }
CmdLogout represents to logout a gitea server.
var CmdNotifications = cli.Command{ Name: "notifications", Usage: "show notifications", Description: "show notifications, by default based of the current repo and unread one", Action: runNotifications, Flags: append([]cli.Flag{ &cli.BoolFlag{ Name: "all", Aliases: []string{"a"}, Usage: "show all notifications of related gitea instance", }, &cli.IntFlag{ Name: "page", Aliases: []string{"p"}, Usage: "specify page, default is 1", Value: 1, }, &cli.IntFlag{ Name: "limit", Aliases: []string{"lm"}, Usage: "specify limit of items per page", }, }, AllDefaultFlags...), }
CmdNotifications is the main command to operate with notifications
var CmdOpen = cli.Command{ Name: "open", Usage: "Open something of the repository on web browser", Description: `Open something of the repository on web browser`, Action: runOpen, Flags: append([]cli.Flag{}, LoginRepoFlags...), }
CmdOpen represents a sub command of issues to open issue on the web browser
var CmdPulls = cli.Command{ Name: "pulls", Aliases: []string{"pull", "pr"}, Usage: "List open pull requests", Description: `List open pull requests`, Action: runPulls, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "state", Usage: "Filter by PR state (all|open|closed)", DefaultText: "open", }, }, AllDefaultFlags...), Subcommands: []*cli.Command{ &CmdPullsCheckout, &CmdPullsClean, &CmdPullsCreate, }, }
CmdPulls is the main command to operate on PRs
var CmdPullsCheckout = cli.Command{ Name: "checkout", Usage: "Locally check out the given PR", Description: `Locally check out the given PR`, Action: runPullsCheckout, ArgsUsage: "<pull index>", Flags: AllDefaultFlags, }
CmdPullsCheckout is a command to locally checkout the given PR
var CmdPullsClean = cli.Command{ Name: "clean", Usage: "Deletes local & remote feature-branches for a closed pull request", Description: `Deletes local & remote feature-branches for a closed pull request`, ArgsUsage: "<pull index>", Action: runPullsClean, Flags: append([]cli.Flag{ &cli.BoolFlag{ Name: "ignore-sha", Usage: "Find the local branch by name instead of commit hash (less precise)", }, }, AllDefaultFlags...), }
CmdPullsClean removes the remote and local feature branches, if a PR is merged.
var CmdPullsCreate = cli.Command{ Name: "create", Usage: "Create a pull-request", Description: "Create a pull-request", Action: runPullsCreate, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "head", Usage: "Set head branch (default is current one)", }, &cli.StringFlag{ Name: "base", Aliases: []string{"b"}, Usage: "Set base branch (default is default branch)", }, &cli.StringFlag{ Name: "title", Aliases: []string{"t"}, Usage: "Set title of pull (default is head branch name)", }, &cli.StringFlag{ Name: "description", Aliases: []string{"d"}, Usage: "Set body of new pull", }, }, AllDefaultFlags...), }
CmdPullsCreate creates a pull request
var CmdReleaseCreate = cli.Command{ Name: "create", Usage: "Create a release", Description: `Create a release`, Action: runReleaseCreate, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "tag", Usage: "Tag name", }, &cli.StringFlag{ Name: "target", Usage: "Target refs, branch name or commit id", }, &cli.StringFlag{ Name: "title", Aliases: []string{"t"}, Usage: "Release title", }, &cli.StringFlag{ Name: "note", Aliases: []string{"n"}, Usage: "Release notes", }, &cli.BoolFlag{ Name: "draft", Aliases: []string{"d"}, Usage: "Is a draft", }, &cli.BoolFlag{ Name: "prerelease", Aliases: []string{"p"}, Usage: "Is a pre-release", }, &cli.StringSliceFlag{ Name: "asset", Aliases: []string{"a"}, Usage: "List of files to attach", }, }, LoginRepoFlags...), }
CmdReleaseCreate represents a sub command of Release to create release.
var CmdReleases = cli.Command{ Name: "releases", Usage: "Create releases", Description: `Create releases`, Action: runReleases, Subcommands: []*cli.Command{ &CmdReleaseCreate, }, Flags: AllDefaultFlags, }
CmdReleases represents to login a gitea server.
var CmdRepos = cli.Command{ Name: "repos", Usage: "Operate with repositories", Description: `Operate with repositories`, Action: runReposList, Subcommands: []*cli.Command{ &CmdReposList, }, Flags: LoginOutputFlags, }
CmdRepos represents to login a gitea server.
var CmdReposList = cli.Command{ Name: "ls", Usage: "List available repositories", Description: `List available repositories`, Action: runReposList, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "mode", Usage: "Filter listed repositories based on mode, optional - fork, mirror, source", }, &cli.StringFlag{ Name: "org", Usage: "Filter listed repositories based on organization, optional", }, &cli.StringFlag{ Name: "user", Usage: "Filter listed repositories absed on user, optional", }, }, LoginOutputFlags...), }
CmdReposList represents a sub command of issues to list issues
var CmdTrackedTimes = cli.Command{ Name: "times", Aliases: []string{"time"}, Usage: "Operate on tracked times of a repository's issues & pulls", Description: `Operate on tracked times of a repository's issues & pulls. Depending on your permissions on the repository, only your own tracked times might be listed.`, ArgsUsage: "[username | #issue]", Action: runTrackedTimes, Subcommands: []*cli.Command{ &CmdTrackedTimesAdd, &CmdTrackedTimesDelete, &CmdTrackedTimesReset, }, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "from", Aliases: []string{"f"}, Usage: "Show only times tracked after this date", }, &cli.StringFlag{ Name: "until", Aliases: []string{"u"}, Usage: "Show only times tracked before this date", }, &cli.BoolFlag{ Name: "total", Aliases: []string{"t"}, Usage: "Print the total duration at the end", }, }, AllDefaultFlags...), }
CmdTrackedTimes represents the command to operate repositories' times.
var CmdTrackedTimesAdd = cli.Command{ Name: "add", Usage: "Track spent time on an issue", UsageText: "tea times add <issue> <duration>", Description: `Track spent time on an issue Example: tea times add 1 1h25m `, Action: runTrackedTimesAdd, Flags: LoginRepoFlags, }
CmdTrackedTimesAdd represents a sub command of times to add time to an issue
var CmdTrackedTimesDelete = cli.Command{ Name: "delete", Aliases: []string{"rm"}, Usage: "Delete a single tracked time on an issue", UsageText: "tea times delete <issue> <time ID>", Action: runTrackedTimesDelete, Flags: LoginRepoFlags, }
CmdTrackedTimesDelete is a sub command of CmdTrackedTimes, and removes time from an issue
var CmdTrackedTimesReset = cli.Command{ Name: "reset", Usage: "Reset tracked time on an issue", UsageText: "tea times reset <issue>", Action: runTrackedTimesReset, Flags: LoginRepoFlags, }
CmdTrackedTimesReset is a subcommand of CmdTrackedTimes, and clears all tracked times on an issue.
var LoginFlag = cli.StringFlag{ Name: "login", Aliases: []string{"l"}, Usage: "Use a different Gitea login. Optional", Destination: &loginValue, }
LoginFlag provides flag to specify tea login profile
var LoginOutputFlags = []cli.Flag{ &LoginFlag, &OutputFlag, }
LoginOutputFlags defines login and output flags that should added to all subcommands and appended to the flags of the subcommand to work around issue and provide --login and --output: https://github.com/urfave/cli/issues/585
var LoginRepoFlags = []cli.Flag{ &LoginFlag, &RepoFlag, &RemoteFlag, }
LoginRepoFlags defines login and repo flags that should be used for all subcommands and appended to the flags of the subcommand to work around issue and provide --login and --repo: https://github.com/urfave/cli/issues/585
var OutputFlag = cli.StringFlag{ Name: "output", Aliases: []string{"o"}, Usage: "Output format. (csv, simple, table, tsv, yaml)", Destination: &outputValue, }
OutputFlag provides flag to specify output type
var RemoteFlag = cli.StringFlag{ Name: "remote", Aliases: []string{"R"}, Usage: "Discover Gitea login from remote. Optional", Destination: &remoteValue, }
RemoteFlag provides flag to specify remote repository
var RepoFlag = cli.StringFlag{ Name: "repo", Aliases: []string{"r"}, Usage: "Repository to interact with. Optional", Destination: &repoValue, }
RepoFlag provides flag to specify repository
Functions ¶
func Errorf ¶
func Errorf(format string, a ...interface{})
Errorf printf content as an error information
Types ¶
type Config ¶
type Config struct {
Logins []Login `yaml:"logins"`
}
Config reprensents local configurations
type Login ¶
type Login struct { Name string `yaml:"name"` URL string `yaml:"url"` Token string `yaml:"token"` Active bool `yaml:"active"` SSHHost string `yaml:"ssh_host"` // optional path to the private key SSHKey string `yaml:"ssh_key"` Insecure bool `yaml:"insecure"` // optional gitea username User string `yaml:"user"` }
Login represents a login to a gitea server, you even could add multiple logins for one gitea server