cmd

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

Tea is command line tool for Gitea.

Index

Constants

This section is empty.

Variables

View Source
var CmdActions = cli.Command{
	Name:        "actions",
	Aliases:     []string{"action"},
	Category:    catEntities,
	Usage:       "Manage repository actions",
	Description: "Manage repository actions including secrets, variables, and workflow runs",
	Action:      runActionsDefault,
	Commands: []*cli.Command{
		&actions.CmdActionsSecrets,
		&actions.CmdActionsVariables,
		&actions.CmdActionsRuns,
		&actions.CmdActionsWorkflows,
	},
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "repo",
			Usage: "repository to operate on",
		},
		&cli.StringFlag{
			Name:  "login",
			Usage: "gitea login instance to use",
		},
		&cli.StringFlag{
			Name:    "output",
			Aliases: []string{"o"},
			Usage:   "output format [table, csv, simple, tsv, yaml, json]",
		},
	},
}

CmdActions represents the actions command for managing Gitea Actions

View Source
var CmdAddComment = cli.Command{
	Name:        "comment",
	Aliases:     []string{"c"},
	Category:    catEntities,
	Usage:       "Add a comment to an issue / pr",
	Description: "Add a comment to an issue / pr",
	ArgsUsage:   "<issue / pr index> [<comment body>]",
	Action:      runAddComment,
	Flags:       flags.AllDefaultFlags,
}

CmdAddComment is the main command to operate with notifications

View Source
var CmdAdmin = cli.Command{
	Name:     "admin",
	Usage:    "Operations requiring admin access on the Gitea instance",
	Aliases:  []string{"a"},
	Category: catMisc,
	Action: func(_ stdctx.Context, cmd *cli.Command) error {
		return cli.ShowSubcommandHelp(cmd)
	},
	Commands: []*cli.Command{
		&cmdAdminUsers,
	},
}

CmdAdmin represents the namespace of admin commands. The command itself has no functionality, but hosts subcommands.

View Source
var CmdApi = cli.Command{
	Name:  "api",
	Usage: "Make an authenticated API request",
	Description: `Makes an authenticated HTTP request to the Gitea API and prints the response.

The endpoint argument is the path to the API endpoint, which will be prefixed
with /api/v1/ if it doesn't start with /api/ or http(s)://.

Placeholders like {owner} and {repo} in the endpoint will be replaced with
values from the current repository context.

Use -f for string fields and -F for typed fields (numbers, booleans, null).
With -F, prefix value with @ to read from file (@- for stdin).`,
	ArgsUsage: "<endpoint>",
	Action:    runApi,
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:    "method",
			Aliases: []string{"X"},
			Usage:   "HTTP method (GET, POST, PUT, PATCH, DELETE)",
			Value:   "GET",
		},
		&cli.StringSliceFlag{
			Name:    "field",
			Aliases: []string{"f"},
			Usage:   "Add a string field to the request body (key=value)",
		},
		&cli.StringSliceFlag{
			Name:    "Field",
			Aliases: []string{"F"},
			Usage:   "Add a typed field to the request body (key=value, @file, or @- for stdin)",
		},
		&cli.StringSliceFlag{
			Name:    "header",
			Aliases: []string{"H"},
			Usage:   "Add a custom header (key:value)",
		},
		&cli.BoolFlag{
			Name:    "include",
			Aliases: []string{"i"},
			Usage:   "Include HTTP status and response headers in output (written to stderr)",
		},
		&cli.StringFlag{
			Name:    "output",
			Aliases: []string{"o"},
			Usage:   "Write response body to file instead of stdout (use '-' for stdout)",
		},
	}, flags.LoginRepoFlags...),
}

CmdApi represents the api command

View Source
var CmdBranches = cli.Command{
	Name:        "branches",
	Aliases:     []string{"branch", "b"},
	Category:    catEntities,
	Usage:       "Consult branches",
	Description: `Lists branches when called without argument. If a branch is provided, will show it in detail.`,
	ArgsUsage:   "[<branch name>]",
	Action:      runBranches,
	Commands: []*cli.Command{
		&branches.CmdBranchesList,
		&branches.CmdBranchesProtect,
		&branches.CmdBranchesUnprotect,
	},
	Flags: append([]cli.Flag{
		&cli.BoolFlag{
			Name:  "comments",
			Usage: "Whether to display comments (will prompt if not provided & run interactively)",
		},
	}, branches.CmdBranchesList.Flags...),
}

CmdBranches represents to login a gitea server.

View Source
var CmdGenerateManPage = cli.Command{
	Name:   "man",
	Usage:  "Generate man page",
	Hidden: true,
	Flags:  DocRenderFlags,
	Action: func(ctx context.Context, cmd *cli.Command) error {
		return RenderDocs(cmd, cmd.Root(), docs.ToMan)
	},
}

CmdGenerateManPage is the sub command to generate the `tea` man page

View Source
var CmdIssues = cli.Command{
	Name:        "issues",
	Aliases:     []string{"issue", "i"},
	Category:    catEntities,
	Usage:       "List, create and update issues",
	Description: `Lists issues when called without argument. If issue index is provided, will show it in detail.`,
	ArgsUsage:   "[<issue index>]",
	Action:      runIssues,
	Commands: []*cli.Command{
		&issues.CmdIssuesList,
		&issues.CmdIssuesCreate,
		&issues.CmdIssuesEdit,
		&issues.CmdIssuesReopen,
		&issues.CmdIssuesClose,
	},
	Flags: append([]cli.Flag{
		&cli.BoolFlag{
			Name:  "comments",
			Usage: "Whether to display comments (will prompt if not provided & run interactively)",
		},
	}, issues.CmdIssuesList.Flags...),
}

CmdIssues represents to login a gitea server.

View Source
var CmdLabels = cli.Command{
	Name:        "labels",
	Aliases:     []string{"label"},
	Category:    catEntities,
	Usage:       "Manage issue labels",
	Description: `Manage issue labels`,
	ArgsUsage:   " ",
	Action:      runLabels,
	Commands: []*cli.Command{
		&labels.CmdLabelsList,
		&labels.CmdLabelCreate,
		&labels.CmdLabelUpdate,
		&labels.CmdLabelDelete,
	},
	Flags: labels.CmdLabelsList.Flags,
}

CmdLabels represents to operate repositories' labels.

View Source
var CmdLogin = cli.Command{
	Name:        "logins",
	Aliases:     []string{"login"},
	Category:    catSetup,
	Usage:       "Log in to a Gitea server",
	Description: `Log in to a Gitea server`,
	ArgsUsage:   "[<login name>]",
	Action:      runLogins,
	Commands: []*cli.Command{
		&login.CmdLoginList,
		&login.CmdLoginAdd,
		&login.CmdLoginEdit,
		&login.CmdLoginDelete,
		&login.CmdLoginSetDefault,
		&login.CmdLoginHelper,
		&login.CmdLoginOAuthRefresh,
	},
}

CmdLogin represents to login a gitea server.

View Source
var CmdLogout = cli.Command{
	Name:        "logout",
	Category:    catSetup,
	Usage:       "Log out from a Gitea server",
	Description: `Log out from a Gitea server`,
	ArgsUsage:   "<login name>",
	Action:      login.RunLoginDelete,
}

CmdLogout represents to logout a gitea server.

View Source
var CmdMilestones = cli.Command{
	Name:        "milestones",
	Aliases:     []string{"milestone", "ms"},
	Category:    catEntities,
	Usage:       "List and create milestones",
	Description: `List and create milestones`,
	ArgsUsage:   "[<milestone name>]",
	Action:      runMilestones,
	Commands: []*cli.Command{
		&milestones.CmdMilestonesList,
		&milestones.CmdMilestonesCreate,
		&milestones.CmdMilestonesClose,
		&milestones.CmdMilestonesDelete,
		&milestones.CmdMilestonesReopen,
		&milestones.CmdMilestonesIssues,
	},
	Flags: milestones.CmdMilestonesList.Flags,
}

CmdMilestones represents to operate repositories milestones.

View Source
var CmdNotifications = cli.Command{
	Name:        "notifications",
	Aliases:     []string{"notification", "n"},
	Category:    catHelpers,
	Usage:       "Show notifications",
	Description: "Show notifications, by default based on the current repo if available",
	Action:      notifications.RunNotificationsList,
	Commands: []*cli.Command{
		&notifications.CmdNotificationsList,
		&notifications.CmdNotificationsMarkRead,
		&notifications.CmdNotificationsMarkUnread,
		&notifications.CmdNotificationsMarkPinned,
		&notifications.CmdNotificationsUnpin,
	},
	Flags: notifications.CmdNotificationsList.Flags,
}

CmdNotifications is the main command to operate with notifications

View Source
var CmdOpen = cli.Command{
	Name:        "open",
	Aliases:     []string{"o"},
	Category:    catHelpers,
	Usage:       "Open something of the repository in web browser",
	Description: `Open something of the repository in web browser`,
	Action:      runOpen,
	Flags:       append([]cli.Flag{}, flags.LoginRepoFlags...),
}

CmdOpen represents a sub command of issues to open issue on the web browser

View Source
var CmdOrgs = cli.Command{
	Name:        "organizations",
	Aliases:     []string{"organization", "org"},
	Category:    catEntities,
	Usage:       "List, create, delete organizations",
	Description: "Show organization details",
	ArgsUsage:   "[<organization>]",
	Action:      runOrganizations,
	Commands: []*cli.Command{
		&organizations.CmdOrganizationList,
		&organizations.CmdOrganizationCreate,
		&organizations.CmdOrganizationDelete,
	},
	Flags: organizations.CmdOrganizationList.Flags,
}

CmdOrgs represents handle organization

View Source
var CmdPulls = cli.Command{
	Name:        "pulls",
	Aliases:     []string{"pull", "pr"},
	Category:    catEntities,
	Usage:       "Manage and checkout pull requests",
	Description: `Lists PRs when called without argument. If PR index is provided, will show it in detail.`,
	ArgsUsage:   "[<pull index>]",
	Action:      runPulls,
	Flags: append([]cli.Flag{
		&cli.BoolFlag{
			Name:  "comments",
			Usage: "Whether to display comments (will prompt if not provided & run interactively)",
		},
	}, pulls.CmdPullsList.Flags...),
	Commands: []*cli.Command{
		&pulls.CmdPullsList,
		&pulls.CmdPullsCheckout,
		&pulls.CmdPullsClean,
		&pulls.CmdPullsCreate,
		&pulls.CmdPullsClose,
		&pulls.CmdPullsReopen,
		&pulls.CmdPullsReview,
		&pulls.CmdPullsApprove,
		&pulls.CmdPullsReject,
		&pulls.CmdPullsMerge,
	},
}

CmdPulls is the main command to operate on PRs

View Source
var CmdReleaseAttachments = cli.Command{
	Name:        "assets",
	Aliases:     []string{"asset", "a"},
	Category:    catEntities,
	Usage:       "Manage release assets",
	Description: "Manage release assets",
	ArgsUsage:   " ",
	Action:      attachments.RunReleaseAttachmentList,
	Commands: []*cli.Command{
		&attachments.CmdReleaseAttachmentList,
		&attachments.CmdReleaseAttachmentCreate,
		&attachments.CmdReleaseAttachmentDelete,
	},
	Flags: flags.AllDefaultFlags,
}

CmdReleaseAttachments represents a release attachment (file attachment)

View Source
var CmdReleases = cli.Command{
	Name:        "releases",
	Aliases:     []string{"release", "r"},
	Category:    catEntities,
	Usage:       "Manage releases",
	Description: "Manage releases",
	ArgsUsage:   " ",
	Action:      releases.RunReleasesList,
	Commands: []*cli.Command{
		&releases.CmdReleaseList,
		&releases.CmdReleaseCreate,
		&releases.CmdReleaseDelete,
		&releases.CmdReleaseEdit,
		&CmdReleaseAttachments,
	},
	Flags: flags.AllDefaultFlags,
}

CmdReleases represents to login a gitea server. ToDo: ReleaseDetails

View Source
var CmdRepoClone = cli.Command{
	Name:    "clone",
	Aliases: []string{"C"},
	Usage:   "Clone a repository locally",
	Description: `Clone a repository locally, without a local git installation required.
The repo slug can be specified in different formats:
	gitea/tea
	tea
	gitea.com/gitea/tea
	git@gitea.com:gitea/tea
	https://gitea.com/gitea/tea
	ssh://gitea.com:22/gitea/tea
When a host is specified in the repo-slug, it will override the login specified with --login.
	`,
	Category:  catHelpers,
	Action:    runRepoClone,
	ArgsUsage: "<repo-slug> [target dir]",
	Flags: []cli.Flag{
		&cli.IntFlag{
			Name:    "depth",
			Aliases: []string{"d"},
			Usage:   "num commits to fetch, defaults to all",
		},
		&flags.LoginFlag,
	},
}

CmdRepoClone represents a sub command of repos to create a local copy

View Source
var CmdRepos = cli.Command{
	Name:        "repos",
	Aliases:     []string{"repo"},
	Category:    catEntities,
	Usage:       "Show repository details",
	Description: "Show repository details",
	ArgsUsage:   "[<repo owner>/<repo name>]",
	Action:      runRepos,
	Commands: []*cli.Command{
		&repos.CmdReposList,
		&repos.CmdReposSearch,
		&repos.CmdRepoCreate,
		&repos.CmdRepoCreateFromTemplate,
		&repos.CmdRepoFork,
		&repos.CmdRepoMigrate,
		&repos.CmdRepoRm,
	},
	Flags: repos.CmdReposListFlags,
}

CmdRepos represents to login a gitea server.

View Source
var CmdTrackedTimes = cli.Command{
	Name:     "times",
	Aliases:  []string{"time", "t"},
	Category: catEntities,
	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:    times.RunTimesList,
	Commands: []*cli.Command{
		&times.CmdTrackedTimesAdd,
		&times.CmdTrackedTimesDelete,
		&times.CmdTrackedTimesReset,
		&times.CmdTrackedTimesList,
	},
	Flags: times.CmdTrackedTimesList.Flags,
}

CmdTrackedTimes represents the command to operate repositories' times.

View Source
var CmdWebhooks = cli.Command{
	Name:        "webhooks",
	Aliases:     []string{"webhook", "hooks", "hook"},
	Category:    catEntities,
	Usage:       "Manage webhooks",
	Description: "List, create, update, and delete repository, organization, or global webhooks",
	ArgsUsage:   "[webhook-id]",
	Action:      runWebhooksDefault,
	Commands: []*cli.Command{
		&webhooks.CmdWebhooksList,
		&webhooks.CmdWebhooksCreate,
		&webhooks.CmdWebhooksDelete,
		&webhooks.CmdWebhooksUpdate,
	},
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:  "repo",
			Usage: "repository to operate on",
		},
		&cli.StringFlag{
			Name:  "org",
			Usage: "organization to operate on",
		},
		&cli.BoolFlag{
			Name:  "global",
			Usage: "operate on global webhooks",
		},
		&cli.StringFlag{
			Name:  "login",
			Usage: "gitea login instance to use",
		},
		&cli.StringFlag{
			Name:    "output",
			Aliases: []string{"o"},
			Usage:   "output format [table, csv, simple, tsv, yaml, json]",
		},
	}, webhooks.CmdWebhooksList.Flags...),
}

CmdWebhooks represents the webhooks command

View Source
var CmdWhoami = cli.Command{
	Name:        "whoami",
	Category:    catMisc,
	Description: `For debugging purposes, show the user that is currently logged in.`,
	Usage:       "Show current logged in user",
	ArgsUsage:   " ",
	Action: func(_ stdctx.Context, cmd *cli.Command) error {
		ctx := context.InitCommand(cmd)
		client := ctx.Login.Client()
		user, _, _ := client.GetMyUserInfo()
		print.UserDetails(user)
		return nil
	},
}

CmdWhoami represents the command to show current logged in user

View Source
var DocRenderFlags = []cli.Flag{
	&cli.StringFlag{
		Name:    "out",
		Usage:   "Path to output docs to, otherwise prints to stdout",
		Aliases: []string{"o"},
	},
}

DocRenderFlags are the flags for documentation generation, used by `./docs/docs.go` and the `generate-man-page` sub command

Functions

func App added in v0.10.0

func App() *cli.Command

App creates and returns a tea Command with all subcommands set it was separated from main so docs can be generated for it

func RenderDocs added in v0.11.0

func RenderDocs(cmd, target *cli.Command, render func(*cli.Command) (string, error)) error

RenderDocs renders the documentation for `target` using the supplied `render` function

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL