1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// 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,
}
}
|