summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-12-15 23:49:01 +0800
committerGitHub <noreply@github.com>2023-12-15 15:49:01 +0000
commit047c69bd85bc5579ce6f352d7edf7fb950d84b80 (patch)
tree0ae581d24c0fcbeb97d943b98835d7b876affedc /cmd
parent3849fd2ac2163b109f9dc1e873ffb9bc8f53c63b (diff)
downloadgitea-047c69bd85bc5579ce6f352d7edf7fb950d84b80.tar.gz
gitea-047c69bd85bc5579ce6f352d7edf7fb950d84b80.zip
Improve CLI code and descriptions (#28482)
* Close #28444 * Actually, it doesn't need to use that trick because it looks like it is not necessary, no user really needs it * Remove the hidden (legacy) "doctor" subcommand and update documents * Fix "actions" usage ![image](https://github.com/go-gitea/gitea/assets/2114189/3c2b34a7-4f92-4a6c-96fd-9505e413d4ec)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/actions.go5
-rw-r--r--cmd/admin.go2
-rw-r--r--cmd/doctor.go2
-rw-r--r--cmd/generate.go2
-rw-r--r--cmd/hook.go4
-rw-r--r--cmd/keys.go9
-rw-r--r--cmd/main.go21
-rw-r--r--cmd/serv.go2
8 files changed, 19 insertions, 28 deletions
diff --git a/cmd/actions.go b/cmd/actions.go
index 052afb9ebc..275fd7904e 100644
--- a/cmd/actions.go
+++ b/cmd/actions.go
@@ -15,9 +15,8 @@ import (
var (
// CmdActions represents the available actions sub-commands.
CmdActions = &cli.Command{
- Name: "actions",
- Usage: "",
- Description: "Commands for managing Gitea Actions",
+ Name: "actions",
+ Usage: "Manage Gitea Actions",
Subcommands: []*cli.Command{
subcmdActionsGenRunnerToken,
},
diff --git a/cmd/admin.go b/cmd/admin.go
index 49d0e4ef74..b5903cd4fd 100644
--- a/cmd/admin.go
+++ b/cmd/admin.go
@@ -21,7 +21,7 @@ var (
// CmdAdmin represents the available admin sub-command.
CmdAdmin = &cli.Command{
Name: "admin",
- Usage: "Command line interface to perform common administrative operations",
+ Usage: "Perform common administrative operations",
Subcommands: []*cli.Command{
subcmdUser,
subcmdRepoSyncReleases,
diff --git a/cmd/doctor.go b/cmd/doctor.go
index 4085d37332..f891b12608 100644
--- a/cmd/doctor.go
+++ b/cmd/doctor.go
@@ -26,7 +26,7 @@ import (
// CmdDoctor represents the available doctor sub-command.
var CmdDoctor = &cli.Command{
Name: "doctor",
- Usage: "Diagnose and optionally fix problems",
+ Usage: "Diagnose and optionally fix problems, convert or re-create database tables",
Description: "A command to diagnose problems with the current Gitea instance according to the given configuration. Some problems can optionally be fixed by modifying the database or data storage.",
Subcommands: []*cli.Command{
diff --git a/cmd/generate.go b/cmd/generate.go
index 5922617217..4ab10da22a 100644
--- a/cmd/generate.go
+++ b/cmd/generate.go
@@ -18,7 +18,7 @@ var (
// CmdGenerate represents the available generate sub-command.
CmdGenerate = &cli.Command{
Name: "generate",
- Usage: "Command line interface for running generators",
+ Usage: "Generate Gitea's secrets/keys/tokens",
Subcommands: []*cli.Command{
subcmdSecret,
},
diff --git a/cmd/hook.go b/cmd/hook.go
index 624569cdfa..6f31c326fd 100644
--- a/cmd/hook.go
+++ b/cmd/hook.go
@@ -31,8 +31,8 @@ var (
// CmdHook represents the available hooks sub-command.
CmdHook = &cli.Command{
Name: "hook",
- Usage: "Delegate commands to corresponding Git hooks",
- Description: "This should only be called by Git",
+ Usage: "(internal) Should only be called by Git",
+ Description: "Delegate commands to corresponding Git hooks",
Before: PrepareConsoleLoggerLevel(log.FATAL),
Subcommands: []*cli.Command{
subcmdHookPreReceive,
diff --git a/cmd/keys.go b/cmd/keys.go
index b846782529..9d5278f109 100644
--- a/cmd/keys.go
+++ b/cmd/keys.go
@@ -16,10 +16,11 @@ import (
// CmdKeys represents the available keys sub-command
var CmdKeys = &cli.Command{
- Name: "keys",
- Usage: "This command queries the Gitea database to get the authorized command for a given ssh key fingerprint",
- Before: PrepareConsoleLoggerLevel(log.FATAL),
- Action: runKeys,
+ Name: "keys",
+ Usage: "(internal) Should only be called by SSH server",
+ Description: "Queries the Gitea database to get the authorized command for a given ssh key fingerprint",
+ Before: PrepareConsoleLoggerLevel(log.FATAL),
+ Action: runKeys,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "expected",
diff --git a/cmd/main.go b/cmd/main.go
index feda41e68b..02dd660e9e 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -10,12 +10,12 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
- "code.gitea.io/gitea/modules/util"
"github.com/urfave/cli/v2"
)
// cmdHelp is our own help subcommand with more information
+// Keep in mind that the "./gitea help"(subcommand) is different from "./gitea --help"(flag), the flag doesn't parse the config or output "DEFAULT CONFIGURATION:" information
func cmdHelp() *cli.Command {
c := &cli.Command{
Name: "help",
@@ -47,16 +47,10 @@ DEFAULT CONFIGURATION:
return c
}
-var helpFlag = cli.HelpFlag
-
-func init() {
- // cli.HelpFlag = nil TODO: after https://github.com/urfave/cli/issues/1794 we can use this
-}
-
func appGlobalFlags() []cli.Flag {
return []cli.Flag{
// make the builtin flags at the top
- helpFlag,
+ cli.HelpFlag,
// shared configuration flags, they are for global and for each sub-command at the same time
// eg: such command is valid: "./gitea --config /tmp/app.ini web --config /tmp/app.ini", while it's discouraged indeed
@@ -121,20 +115,22 @@ func prepareWorkPathAndCustomConf(action cli.ActionFunc) func(ctx *cli.Context)
func NewMainApp(version, versionExtra string) *cli.App {
app := cli.NewApp()
app.Name = "Gitea"
+ app.HelpName = "gitea"
app.Usage = "A painless self-hosted Git service"
- app.Description = `By default, Gitea will start serving using the web-server with no argument, which can alternatively be run by running the subcommand "web".`
+ app.Description = `Gitea program contains "web" and other subcommands. If no subcommand is given, it starts the web server by default. Use "web" subcommand for more web server arguments, use other subcommands for other purposes.`
app.Version = version + versionExtra
app.EnableBashCompletion = true
// these sub-commands need to use config file
subCmdWithConfig := []*cli.Command{
+ cmdHelp(), // the "help" sub-command was used to show the more information for "work path" and "custom config"
CmdWeb,
CmdServ,
CmdHook,
+ CmdKeys,
CmdDump,
CmdAdmin,
CmdMigrate,
- CmdKeys,
CmdDoctor,
CmdManager,
CmdEmbedded,
@@ -142,13 +138,8 @@ func NewMainApp(version, versionExtra string) *cli.App {
CmdDumpRepository,
CmdRestoreRepository,
CmdActions,
- cmdHelp(), // the "help" sub-command was used to show the more information for "work path" and "custom config"
}
- cmdConvert := util.ToPointer(*cmdDoctorConvert)
- cmdConvert.Hidden = true // still support the legacy "./gitea doctor" by the hidden sub-command, remove it in next release
- subCmdWithConfig = append(subCmdWithConfig, cmdConvert)
-
// these sub-commands do not need the config file, and they do not depend on any path or environment variable.
subCmdStandalone := []*cli.Command{
CmdCert,
diff --git a/cmd/serv.go b/cmd/serv.go
index 26fc91a3b7..726663660b 100644
--- a/cmd/serv.go
+++ b/cmd/serv.go
@@ -42,7 +42,7 @@ const (
// CmdServ represents the available serv sub-command.
var CmdServ = &cli.Command{
Name: "serv",
- Usage: "This command should only be called by SSH shell",
+ Usage: "(internal) Should only be called by SSH shell",
Description: "Serv provides access auth for repositories",
Before: PrepareConsoleLoggerLevel(log.FATAL),
Action: runServ,