Migrate to github.com/urfave/cli/v3 (#2951)

This commit is contained in:
6543
2024-07-17 16:26:35 -07:00
committed by GitHub
parent e39345688d
commit cd5f6f71a2
112 changed files with 817 additions and 673 deletions

View File

@@ -15,7 +15,7 @@
package main
import (
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
"go.woodpecker-ci.org/woodpecker/v2/cli/admin"
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
@@ -38,12 +38,12 @@ import (
)
//go:generate go run docs.go app.go
func newApp() *cli.App {
app := cli.NewApp()
func newApp() *cli.Command {
app := &cli.Command{}
app.Name = "woodpecker-cli"
app.Description = "Woodpecker command line utility"
app.Version = version.String()
app.EnableBashCompletion = true
app.Usage = "command line utility"
app.Flags = common.GlobalFlags
app.Before = common.Before
app.After = common.After

View File

@@ -19,11 +19,13 @@ package main
import (
"os"
docs "github.com/urfave/cli-docs/v3"
)
func main() {
app := newApp()
md, err := app.ToMarkdown()
md, err := docs.ToMarkdown(app)
if err != nil {
panic(err)
}

View File

@@ -15,15 +15,22 @@
package main
import (
"context"
"os"
_ "github.com/joho/godotenv/autoload"
"github.com/rs/zerolog/log"
"go.woodpecker-ci.org/woodpecker/v2/shared/utils"
)
func main() {
ctx := utils.WithContextSigtermCallback(context.Background(), func() {
log.Info().Msg("termination signal is received, terminate cli")
})
app := newApp()
if err := app.Run(os.Args); err != nil {
if err := app.Run(ctx, os.Args); err != nil {
log.Fatal().Err(err).Msg("error running cli") //nolint:forbidigo
}
}