mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-03-15 17:13:46 +01:00
Migrate to github.com/urfave/cli/v3 (#2951)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user