chore(deps): upgrade urfave/cli from v1 to v3

Migrate from urfave/cli v1 (maintenance mode) to v3 to benefit from
active development, improved features, and long-term support.

Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
lifubang
2026-03-18 03:00:21 +00:00
parent 84762a5c1a
commit 57fad01d52
124 changed files with 8429 additions and 13736 deletions
+11 -10
View File
@@ -5,13 +5,14 @@
package main
import (
"context"
"errors"
"fmt"
"net"
"os"
"os/signal"
"github.com/urfave/cli"
"github.com/urfave/cli/v3"
"golang.org/x/sys/unix"
"github.com/opencontainers/runc/internal/cmsg"
@@ -32,32 +33,32 @@ pidfd:
)
func main() {
app := cli.NewApp()
app := &cli.Command{}
app.Name = "pidfd-kill"
app.Usage = usage
app.Flags = []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "signal",
Value: "SIGKILL",
Usage: "Signal to send to the init process",
},
cli.StringFlag{
&cli.StringFlag{
Name: "pid-file",
Value: "",
Usage: "Path to write the pidfd-kill process ID to",
},
}
app.Action = func(ctx *cli.Context) error {
args := ctx.Args()
app.Action = func(_ context.Context, cmd *cli.Command) error {
args := cmd.Args().Slice()
if len(args) != 1 {
return errors.New("required a single socket path")
}
socketFile := ctx.Args()[0]
socketFile := args[0]
pidFile := ctx.String("pid-file")
pidFile := cmd.String("pid-file")
if pidFile != "" {
pid := fmt.Sprintf("%d\n", os.Getpid())
if err := os.WriteFile(pidFile, []byte(pid), 0o644); err != nil {
@@ -66,7 +67,7 @@ func main() {
defer os.Remove(pidFile)
}
sigStr := ctx.String("signal")
sigStr := cmd.String("signal")
if sigStr == "" {
sigStr = "SIGKILL"
}
@@ -84,7 +85,7 @@ func main() {
return unix.PidfdSendSignal(int(pidfdFile.Fd()), sig, nil, 0)
}
if err := app.Run(os.Args); err != nil {
if err := app.Run(context.Background(), os.Args); err != nil {
fmt.Fprintln(os.Stderr, "fatal error:", err)
os.Exit(1)
}