@@ -47,7 +47,9 @@ func init() {
47
47
// ./gitea -h
48
48
// ./gitea web help
49
49
// ./gitea web -h (due to cli lib limitation, this won't call our cmdHelp, so no extra info)
50
- // ./gitea admin help auth
50
+ // ./gitea admin
51
+ // ./gitea admin help
52
+ // ./gitea admin auth help
51
53
// ./gitea -c /tmp/app.ini -h
52
54
// ./gitea -c /tmp/app.ini help
53
55
// ./gitea help -c /tmp/app.ini
@@ -156,11 +158,7 @@ func prepareSubcommands(command *cli.Command, defaultFlags []cli.Flag) {
156
158
157
159
// prepareWorkPathAndCustomConf wraps the Action to prepare the work path and custom config
158
160
// It can't use "Before", because each level's sub-command's Before will be called one by one, so the "init" would be done multiple times
159
- func prepareWorkPathAndCustomConf (a any ) func (ctx * cli.Context ) error {
160
- if a == nil {
161
- return nil
162
- }
163
- action := a .(func (* cli.Context ) error )
161
+ func prepareWorkPathAndCustomConf (action any ) func (ctx * cli.Context ) error {
164
162
return func (ctx * cli.Context ) error {
165
163
var args setting.ArgWorkPathAndCustomConf
166
164
curCtx := ctx
@@ -177,10 +175,11 @@ func prepareWorkPathAndCustomConf(a any) func(ctx *cli.Context) error {
177
175
curCtx = curCtx .Parent ()
178
176
}
179
177
setting .InitWorkPathAndCommonConfig (os .Getenv , args )
180
- if ctx .Bool ("help" ) {
178
+ if ctx .Bool ("help" ) || action == nil {
179
+ // the default behavior of "urfave/cli": "nil action" means "show help"
181
180
return cmdHelp .Action .(func (ctx * cli.Context ) error )(ctx )
182
181
}
183
- return action (ctx )
182
+ return action .( func ( * cli. Context ) error ) (ctx )
184
183
}
185
184
}
186
185
0 commit comments