mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-06 03:08:44 +02:00
06e4d16bf3
## Summary Add first-class `tea wiki` commands backed by the existing Gitea wiki API and SDK support. ## What this adds - `tea wiki list` - `tea wiki view <page>` - `tea wiki revisions <page>` - `tea wiki create` - `tea wiki edit <page>` - `tea wiki delete <page>` ## Implementation details - registers a new top-level `wiki` entity command - keeps command logic under `cmd/wiki/` - adds wiki-specific renderers in `modules/print/wiki.go` - adds wiki task helpers in `modules/task/wiki.go` - reuses existing repo/login/output/pagination patterns used elsewhere in `tea` - base64-encodes wiki content for create/edit API calls - requires explicit `--confirm` for delete - preserves the current page title during edit when `--title` is omitted ## Test coverage The PR is intentionally split into two commits: 1. `feat: add wiki CLI commands` 2. `test: add wiki integration coverage` Validation performed: - focused command, task, and print tests for the new wiki functionality - integration coverage for the wiki command lifecycle - `make lint` - `make fmt-check` - `make docs-check` - `make build` - upstream PR CI passed: - `check-and-test / Integration Test` - `check-and-test / Lint Build And Unit Coverage` ## Motivation This makes `tea` a better interface for both human and agent-driven workflows by exposing wiki operations as stable first-class CLI commands instead of requiring ad-hoc API calls or custom wrappers. --- Generated by Hermes Agent with GPT-5.4 --------- Co-authored-by: nitro <nitro@nitroui-Macmini.local> Reviewed-on: https://gitea.com/gitea/tea/pulls/998 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: kuil09 <202447+kuil09@noreply.gitea.com> Co-committed-by: kuil09 <202447+kuil09@noreply.gitea.com>
112 lines
3.7 KiB
Go
112 lines
3.7 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// Tea is command line tool for Gitea.
|
|
package cmd // import "gitea.dev/tea"
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/urfave/cli/v3"
|
|
|
|
"gitea.dev/tea/modules/version"
|
|
)
|
|
|
|
// App creates and returns a tea Command with all subcommands set
|
|
// it was separated from main so docs can be generated for it
|
|
func App() *cli.Command {
|
|
// make parsing tea --version easier, by printing /just/ the version string
|
|
cli.VersionPrinter = func(c *cli.Command) { fmt.Fprintln(c.Writer, c.Version) }
|
|
|
|
return &cli.Command{
|
|
Name: "tea",
|
|
Usage: "command line tool to interact with Gitea",
|
|
Description: appDescription,
|
|
CustomHelpTemplate: helpTemplate,
|
|
Version: version.Format(),
|
|
Commands: []*cli.Command{
|
|
&CmdLogin,
|
|
&CmdLogout,
|
|
&CmdWhoami,
|
|
|
|
&CmdIssues,
|
|
&CmdPulls,
|
|
&CmdLabels,
|
|
&CmdMilestones,
|
|
&CmdReleases,
|
|
&CmdTrackedTimes,
|
|
&CmdOrgs,
|
|
&CmdRepos,
|
|
&CmdBranches,
|
|
&CmdActions,
|
|
&CmdWiki,
|
|
&CmdWebhooks,
|
|
&CmdAddComment,
|
|
|
|
&CmdOpen,
|
|
&CmdNotifications,
|
|
&CmdRepoClone,
|
|
|
|
&CmdSSHKeys,
|
|
|
|
&CmdAdmin,
|
|
|
|
&CmdApi,
|
|
&CmdGenerateManPage,
|
|
},
|
|
EnableShellCompletion: true,
|
|
}
|
|
}
|
|
|
|
var appDescription = `tea is a productivity helper for Gitea. It can be used to manage most entities on
|
|
one or multiple Gitea instances & provides local helpers like 'tea pr checkout'.
|
|
|
|
tea tries to make use of context provided by the repository in $PWD if available.
|
|
tea works best in a upstream/fork workflow, when the local main branch tracks the
|
|
upstream repo. tea assumes that local git state is published on the remote before
|
|
doing operations with tea. Configuration is persisted in $XDG_CONFIG_HOME/tea.
|
|
`
|
|
|
|
var helpTemplate = fmt.Sprintf("\033[1m%s\033[0m", `
|
|
{{.Name}}{{if .Usage}} - {{.Usage}}{{end}}`) + `
|
|
{{if .Version}}{{if not .HideVersion}}version {{.Version}}{{end}}{{end}}
|
|
|
|
USAGE
|
|
{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}{{if .Commands}} command [subcommand] [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}}
|
|
|
|
DESCRIPTION
|
|
{{.Description | nindent 3 | trim}}{{end}}{{if .VisibleCommands}}
|
|
|
|
COMMANDS{{range .VisibleCategories}}{{if .Name}}
|
|
{{.Name}}:{{range .VisibleCommands}}
|
|
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
|
|
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
|
|
|
|
OPTIONS
|
|
{{range $index, $option := .VisibleFlags}}{{if $index}}
|
|
{{end}}{{$option}}{{end}}{{end}}
|
|
|
|
EXAMPLES
|
|
tea login add # add a login once to get started
|
|
|
|
tea pulls # list open pulls for the repo in $PWD
|
|
tea pulls --repo $HOME/foo # list open pulls for the repo in $HOME/foo
|
|
tea pulls --remote upstream # list open pulls for the repo pointed at by
|
|
# your local "upstream" git remote
|
|
# list open pulls for any gitea repo at the given login instance
|
|
tea pulls --repo gitea/tea --login gitea.com
|
|
|
|
tea milestone issues 0.7.0 # view open issues for milestone '0.7.0'
|
|
tea issue 189 # view contents of issue 189
|
|
tea open 189 # open web ui for issue 189
|
|
tea open milestones # open web ui for milestones
|
|
|
|
# send gitea desktop notifications every 5 minutes (bash + libnotify)
|
|
while :; do tea notifications --mine -o simple | xargs -i notify-send {}; sleep 300; done
|
|
|
|
ABOUT
|
|
Written & maintained by The Gitea Authors.
|
|
If you find a bug or want to contribute, we'll welcome you at https://gitea.com/gitea/tea.
|
|
More info about Gitea itself on https://about.gitea.com.
|
|
`
|