Update cli to v3

This commit is contained in:
2025-03-20 18:53:23 +01:00
parent 1230fb52d7
commit 9b54cec29c
4 changed files with 9 additions and 24 deletions

View File

@@ -17,20 +17,14 @@ import (
"git.t-juice.club/torjus/apiary/web"
"github.com/coreos/go-systemd/daemon"
sshlib "github.com/gliderlabs/ssh"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
"golang.org/x/crypto/acme/autocert"
)
func main() {
app := &cli.App{
app := &cli.Command{
Name: "apiary",
Version: apiary.FullVersion(),
Authors: []*cli.Author{
{
Name: "Torjus Håkestad",
Email: "torjus@usit.uio.no",
},
},
Commands: []*cli.Command{
{
Name: "serve",
@@ -40,13 +34,13 @@ func main() {
},
}
if err := app.Run(os.Args); err != nil {
if err := app.Run(context.Background(), os.Args); err != nil {
fmt.Printf("Error: %s\n", err)
os.Exit(1)
}
}
func ActionServe(c *cli.Context) error {
func ActionServe(ctx context.Context, cmd *cli.Command) error {
cfg, err := getConfig()
if err != nil {
return err
@@ -90,7 +84,7 @@ func ActionServe(c *cli.Context) error {
interruptChan := make(chan os.Signal, 1)
signal.Notify(interruptChan, os.Interrupt)
rootCtx, rootCancel := context.WithCancel(c.Context)
rootCtx, rootCancel := context.WithCancel(ctx)
defer rootCancel()
serversCtx, serversCancel := context.WithCancel(rootCtx)
defer serversCancel()