1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-15 15:07:20 +00:00

Migrate to urfave v3 (#34510)

migrate cli to urfave v3

add more cli tests

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
TheFox0x7
2025-06-10 14:35:12 +02:00
committed by GitHub
parent 2c341b6803
commit e9f5105e95
51 changed files with 1718 additions and 783 deletions

View File

@ -4,6 +4,7 @@
package cmd
import (
"context"
"errors"
"fmt"
"strings"
@ -11,7 +12,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/private"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)
// CmdKeys represents the available keys sub-command
@ -49,7 +50,7 @@ var CmdKeys = &cli.Command{
},
}
func runKeys(c *cli.Context) error {
func runKeys(ctx context.Context, c *cli.Command) error {
if !c.IsSet("username") {
return errors.New("No username provided")
}
@ -68,9 +69,6 @@ func runKeys(c *cli.Context) error {
return errors.New("No key type and content provided")
}
ctx, cancel := installSignals()
defer cancel()
setup(ctx, c.Bool("debug"))
authorizedString, extra := private.AuthorizedPublicKeyByContent(ctx, content)
@ -78,6 +76,6 @@ func runKeys(c *cli.Context) error {
if extra.Error != nil {
return extra.Error
}
_, _ = fmt.Fprintln(c.App.Writer, strings.TrimSpace(authorizedString.Text))
_, _ = fmt.Fprintln(c.Root().Writer, strings.TrimSpace(authorizedString.Text))
return nil
}