1
0
Fork 0
golang-forgejo-f3-gof3/cmd/main.go
Daniel Baumann 03bfe4079e
Adding upstream version 3.10.8.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-05-18 09:37:23 +02:00

49 lines
998 B
Go

// Copyright Earl Warren <contact@earl-warren.org>
// Copyright Loïc Dachary <loic@dachary.org>
// SPDX-License-Identifier: MIT
package cmd
import (
"context"
"code.forgejo.org/f3/gof3/v3/logger"
"github.com/urfave/cli/v3"
)
var Version = "development"
func SetVerbosity(ctx context.Context, verbosity int) {
l := logger.ContextGetLogger(ctx)
switch verbosity {
case 0:
l.SetLevel(logger.Info)
default:
l.SetLevel(logger.Trace)
}
}
func NewApp() *cli.Command {
return &cli.Command{
Name: "F3",
Usage: "Friendly Forge Format",
Description: `Friendly Forge Format`,
Version: Version,
Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
SetVerbosity(ctx, c.Count("verbose"))
return nil, nil
},
Commands: []*cli.Command{
CreateCmdMirror(),
},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "verbose",
Usage: "increase the verbosity level",
},
cli.VersionFlag,
},
EnableShellCompletion: true,
}
}