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, create and update issues", Description: "List, create and update issues", ArgsUsage: "[<issue index>]", Action: runIssues, Subcommands: []*cli.Command{ &CmdIssuesList, &CmdIssuesCreate, &CmdIssuesReopen, &CmdIssuesClose, }, Flags: IssuePRFlags, }
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: IssuePRFlags, }
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: runLabelDelete,
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", }, &PaginationPageFlag, &PaginationLimitFlag, }, 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: runLoginAddInteractive,
Subcommands: []*cli.Command{
&cmdLoginList,
&cmdLoginAdd,
&cmdLoginEdit,
&cmdLoginSetDefault,
},
}
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 CmdMilestoneAddIssue = cli.Command{ Name: "add", Aliases: []string{"a"}, Usage: "Add an issue/pull to an milestone", Description: "Add an issue/pull to an milestone", ArgsUsage: "<milestone name> <issue/pull index>", Action: runMilestoneIssueAdd, Flags: AllDefaultFlags, }
CmdMilestoneAddIssue represents a sub command of milestone issues to add an issue/pull to an milestone
var CmdMilestoneRemoveIssue = cli.Command{ Name: "remove", Aliases: []string{"r"}, Usage: "Remove an issue/pull to an milestone", Description: "Remove an issue/pull to an milestone", ArgsUsage: "<milestone name> <issue/pull index>", Action: runMilestoneIssueRemove, Flags: AllDefaultFlags, }
CmdMilestoneRemoveIssue represents a sub command of milestones to remove an issue/pull from an milestone
var CmdMilestones = cli.Command{ Name: "milestones", Aliases: []string{"ms", "mile"}, Usage: "List and create milestones", Description: `List and create milestones`, ArgsUsage: "[<milestone name>]", Action: runMilestones, Subcommands: []*cli.Command{ &CmdMilestonesList, &CmdMilestonesCreate, &CmdMilestonesClose, &CmdMilestonesDelete, &CmdMilestonesReopen, &CmdMilestonesIssues, }, Flags: AllDefaultFlags, }
CmdMilestones represents to operate repositories milestones.
var CmdMilestonesClose = cli.Command{ Name: "close", Usage: "Change state of an milestone to 'closed'", Description: `Change state of an milestone to 'closed'`, ArgsUsage: "<milestone name>", Action: func(ctx *cli.Context) error { if ctx.Bool("force") { return deleteMilestone(ctx) } return editMilestoneStatus(ctx, true) }, Flags: append([]cli.Flag{ &cli.BoolFlag{ Name: "force", Aliases: []string{"f"}, Usage: "delete milestone", }, }, AllDefaultFlags...), }
CmdMilestonesClose represents a sub command of milestones to close an milestone
var CmdMilestonesCreate = cli.Command{ Name: "create", Usage: "Create an milestone on repository", Description: `Create an milestone on repository`, Action: runMilestonesCreate, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "title", Aliases: []string{"t"}, Usage: "milestone title to create", }, &cli.StringFlag{ Name: "description", Aliases: []string{"d"}, Usage: "milestone description to create", }, &cli.StringFlag{ Name: "state", Usage: "set milestone state (default is open)", DefaultText: "open", }, }, AllDefaultFlags...), }
CmdMilestonesCreate represents a sub command of milestones to create milestone
var CmdMilestonesDelete = cli.Command{ Name: "delete", Aliases: []string{"rm"}, Usage: "delete a milestone", Description: "delete a milestone", ArgsUsage: "<milestone name>", Action: deleteMilestone, Flags: AllDefaultFlags, }
CmdMilestonesDelete represents a sub command of milestones to delete an milestone
var CmdMilestonesIssues = cli.Command{ Name: "issues", Aliases: []string{"i"}, Usage: "manage issue/pull of an milestone", Description: "manage issue/pull of an milestone", ArgsUsage: "<milestone name>", Action: runMilestoneIssueList, Subcommands: []*cli.Command{ &CmdMilestoneAddIssue, &CmdMilestoneRemoveIssue, }, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "state", Usage: "Filter by issue state (all|open|closed)", DefaultText: "open", }, &cli.StringFlag{ Name: "kind", Usage: "Filter by kind (issue|pull)", }, &PaginationPageFlag, &PaginationLimitFlag, }, AllDefaultFlags...), }
CmdMilestonesIssues represents a sub command of milestones to manage issue/pull of an milestone
var CmdMilestonesList = cli.Command{ Name: "ls", Usage: "List milestones of the repository", Description: `List milestones of the repository`, Action: runMilestonesList, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "state", Usage: "Filter by milestone state (all|open|closed)", DefaultText: "open", }, &PaginationPageFlag, &PaginationLimitFlag, }, AllDefaultFlags...), }
CmdMilestonesList represents a sub command of milestones to list milestones
var CmdMilestonesReopen = cli.Command{ Name: "reopen", Aliases: []string{"open"}, Usage: "Change state of an milestone to 'open'", Description: `Change state of an milestone to 'open'`, ArgsUsage: "<milestone name>", Action: func(ctx *cli.Context) error { return editMilestoneStatus(ctx, false) }, Flags: AllDefaultFlags, }
CmdMilestonesReopen represents a sub command of milestones to open an milestone
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.BoolFlag{ Name: "read", Aliases: []string{"rd"}, Usage: "show read notifications instead unread", }, &cli.BoolFlag{ Name: "pinned", Aliases: []string{"pd"}, Usage: "show pinned notifications instead unread", }, &PaginationPageFlag, &PaginationLimitFlag, }, 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, create, checkout and clean pull requests", Description: `List, create, checkout and clean pull requests`, ArgsUsage: "[<pull index>]", Action: runPulls, Flags: IssuePRFlags, Subcommands: []*cli.Command{ &CmdPullsList, &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 CmdPullsList = cli.Command{ Name: "ls", Usage: "List pull requests of the repository", Description: `List pull requests of the repository`, Action: runPullsList, Flags: IssuePRFlags, }
CmdPullsList represents a sub command of issues to list pulls
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", }, }, AllDefaultFlags...), }
CmdReleaseCreate represents a sub command of Release to create release
var CmdReleaseDelete = cli.Command{ Name: "delete", Usage: "Delete a release", Description: `Delete a release`, ArgsUsage: "<release tag>", Action: runReleaseDelete, Flags: AllDefaultFlags, }
CmdReleaseDelete represents a sub command of Release to delete a release
var CmdReleaseEdit = cli.Command{ Name: "edit", Usage: "Edit a release", Description: `Edit a release`, ArgsUsage: "<release tag>", Action: runReleaseEdit, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "tag", Usage: "Change Tag", }, &cli.StringFlag{ Name: "target", Usage: "Change Target", }, &cli.StringFlag{ Name: "title", Aliases: []string{"t"}, Usage: "Change Title", }, &cli.StringFlag{ Name: "note", Aliases: []string{"n"}, Usage: "Change Notes", }, &cli.StringFlag{ Name: "draft", Aliases: []string{"d"}, Usage: "Mark as Draft [True/false]", DefaultText: "true", }, &cli.StringFlag{ Name: "prerelease", Aliases: []string{"p"}, Usage: "Mark as Pre-Release [True/false]", DefaultText: "true", }, }, AllDefaultFlags...), }
CmdReleaseEdit represents a sub command of Release to edit releases
var CmdReleaseList = cli.Command{ Name: "ls", Usage: "List Releases", Description: "List Releases", Action: runReleases, Flags: append([]cli.Flag{ &PaginationPageFlag, &PaginationLimitFlag, }, AllDefaultFlags...), }
CmdReleaseList represents a sub command of Release to list releases
var CmdReleases = cli.Command{ Name: "release", Aliases: []string{"releases"}, Usage: "Manage releases", Description: "Manage releases", Action: runReleases, Subcommands: []*cli.Command{ &CmdReleaseList, &CmdReleaseCreate, &CmdReleaseDelete, &CmdReleaseEdit, }, Flags: AllDefaultFlags, }
CmdReleases represents to login a gitea server.
var CmdRepoCreate = cli.Command{ Name: "create", Aliases: []string{"c"}, Usage: "Create a repository", Description: "Create a repository", Action: runRepoCreate, Flags: append([]cli.Flag{ &cli.StringFlag{ Name: "name", Aliases: []string{""}, Required: true, Usage: "name of new repo", }, &cli.StringFlag{ Name: "owner", Aliases: []string{"O"}, Required: false, Usage: "name of repo owner", }, &cli.BoolFlag{ Name: "private", Required: false, Value: false, Usage: "make repo private", }, &cli.StringFlag{ Name: "description", Aliases: []string{"desc"}, Required: false, Usage: "add description to repo", }, &cli.BoolFlag{ Name: "init", Required: false, Value: false, Usage: "initialize repo", }, &cli.StringFlag{ Name: "labels", Required: false, Usage: "name of label set to add", }, &cli.StringFlag{ Name: "gitignores", Aliases: []string{"git"}, Required: false, Usage: "list of gitignore templates (need --init)", }, &cli.StringFlag{ Name: "license", Required: false, Usage: "add license (need --init)", }, &cli.StringFlag{ Name: "readme", Required: false, Usage: "use readme template (need --init)", }, &cli.StringFlag{ Name: "branch", Required: false, Usage: "use custom default branch (need --init)", }, }, LoginOutputFlags...), }
CmdRepoCreate represents a sub command of repos to create one
var CmdRepos = cli.Command{ Name: "repos", Usage: "Show repositories details", Description: "Show repositories details", ArgsUsage: "[<repo owner>/<repo name>]", Action: runRepos, Subcommands: []*cli.Command{ &CmdReposList, &CmdRepoCreate, }, 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", Aliases: []string{"m"}, Required: false, Usage: "Filter by mode: fork, mirror, source", }, &cli.StringFlag{ Name: "owner", Aliases: []string{"O"}, Required: false, Usage: "Filter by owner", }, &cli.StringFlag{ Name: "private", Required: false, Usage: "Filter private repos (true|false)", }, &cli.StringFlag{ Name: "archived", Required: false, Usage: "Filter archived repos (true|false)", }, &PaginationPageFlag, &PaginationLimitFlag, }, LoginOutputFlags...), }
CmdReposList represents a sub command of repos to list them
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 IssuePRFlags = append([]cli.Flag{ &StateFlag, &PaginationPageFlag, &PaginationLimitFlag, }, AllDefaultFlags...)
IssuePRFlags defines flags that should be available on issue & pr listing flags.
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 PaginationLimitFlag = cli.StringFlag{ Name: "limit", Aliases: []string{"lm"}, Usage: "specify limit of items per page", }
PaginationLimitFlag provides flag for pagination options
var PaginationPageFlag = cli.StringFlag{ Name: "page", Aliases: []string{"p"}, Usage: "specify page, default is 1", }
PaginationPageFlag provides flag for pagination options
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
var StateFlag = cli.StringFlag{
Name: "state",
Usage: "Filter by state (all|open|closed)",
DefaultText: "open",
}
StateFlag provides flag to specify issue/pr state, defaulting to "open"
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"` Default bool `yaml:"default"` 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