mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-18 23:09:43 +00:00
[F3] implement --quiet, --debug, --verbose
This commit is contained in:
parent
4d098e9b83
commit
82e2e17b45
|
@ -7,6 +7,8 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
|
||||
_ "code.gitea.io/gitea/services/f3/driver" // register the driver
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
f3_cmd "lab.forgefriends.org/friendlyforgeformat/gof3/cmd"
|
||||
)
|
||||
|
|
|
@ -33,7 +33,11 @@ func CmdForgejo(ctx context.Context) *cli.Command {
|
|||
return &cli.Command{
|
||||
Name: "forgejo-cli",
|
||||
Usage: "Forgejo CLI",
|
||||
Flags: []cli.Flag{},
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "debug",
|
||||
},
|
||||
},
|
||||
Subcommands: []*cli.Command{
|
||||
CmdActions(ctx),
|
||||
CmdF3(ctx),
|
||||
|
|
17
cmd/main.go
17
cmd/main.go
|
@ -130,6 +130,7 @@ func NewMainApp(version, versionExtra string) *cli.App {
|
|||
|
||||
var subCmdsStandalone []*cli.Command = make([]*cli.Command, 0, 10)
|
||||
var subCmdWithConfig []*cli.Command = make([]*cli.Command, 0, 10)
|
||||
var globalFlags []cli.Flag = make([]cli.Flag, 0, 10)
|
||||
|
||||
//
|
||||
// If the executable is forgejo-cli, provide a Forgejo specific CLI
|
||||
|
@ -138,6 +139,17 @@ func NewMainApp(version, versionExtra string) *cli.App {
|
|||
if executable == "forgejo-cli" {
|
||||
subCmdsStandalone = append(subCmdsStandalone, forgejo.CmdActions(context.Background()))
|
||||
subCmdWithConfig = append(subCmdWithConfig, forgejo.CmdF3(context.Background()))
|
||||
globalFlags = append(globalFlags, []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "quiet",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "verbose",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "debug",
|
||||
},
|
||||
}...)
|
||||
} else {
|
||||
//
|
||||
// Otherwise provide a Gitea compatible CLI which includes Forgejo
|
||||
|
@ -149,10 +161,10 @@ func NewMainApp(version, versionExtra string) *cli.App {
|
|||
subCmdWithConfig = append(subCmdWithConfig, CmdActions)
|
||||
}
|
||||
|
||||
return innerNewMainApp(version, versionExtra, subCmdsStandalone, subCmdWithConfig)
|
||||
return innerNewMainApp(version, versionExtra, subCmdsStandalone, subCmdWithConfig, globalFlags)
|
||||
}
|
||||
|
||||
func innerNewMainApp(version, versionExtra string, subCmdsStandaloneArgs, subCmdWithConfigArgs []*cli.Command) *cli.App {
|
||||
func innerNewMainApp(version, versionExtra string, subCmdsStandaloneArgs, subCmdWithConfigArgs []*cli.Command, globalFlagsArgs []cli.Flag) *cli.App {
|
||||
app := cli.NewApp()
|
||||
app.Name = "Gitea"
|
||||
app.Usage = "A painless self-hosted Git service"
|
||||
|
@ -194,6 +206,7 @@ func innerNewMainApp(version, versionExtra string, subCmdsStandaloneArgs, subCmd
|
|||
app.DefaultCommand = CmdWeb.Name
|
||||
|
||||
globalFlags := appGlobalFlags()
|
||||
globalFlags = append(globalFlags, globalFlagsArgs...)
|
||||
app.Flags = append(app.Flags, cli.VersionFlag)
|
||||
app.Flags = append(app.Flags, globalFlags...)
|
||||
app.HideHelp = true // use our own help action to show helps (with more information like default config)
|
||||
|
|
Loading…
Reference in a new issue