mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-11 06:29:15 -06:00
groupware: migrate to cobra instead of urfave
This commit is contained in:
@@ -265,7 +265,7 @@ var serviceCommands = []register.Command{
|
||||
cfg.Webfinger.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
return ServiceCommand(cfg, cfg.AuthApi.Service.Name, authapi.GetCommands(cfg.AuthApi), func(c *config.Config) {
|
||||
cfg.AuthApi.Commons = cfg.Commons
|
||||
})
|
||||
|
||||
@@ -5,23 +5,29 @@ import (
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/clihelper"
|
||||
"github.com/opencloud-eu/opencloud/services/auth-api/pkg/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// GetCommands provides all commands for this service
|
||||
func GetCommands(cfg *config.Config) cli.Commands {
|
||||
return []*cli.Command{
|
||||
func GetCommands(cfg *config.Config) []*cobra.Command {
|
||||
return []*cobra.Command{
|
||||
// start this service
|
||||
Server(cfg),
|
||||
// infos about this service
|
||||
// Health(cfg),
|
||||
Version(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
// Execute is the entry point for the opencloud group command.
|
||||
func Execute(cfg *config.Config) error {
|
||||
app := clihelper.DefaultApp(&cli.App{
|
||||
Name: "auth-api",
|
||||
Usage: "OpenCloud authentication API for external services",
|
||||
Commands: GetCommands(cfg),
|
||||
app := clihelper.DefaultApp(&cobra.Command{
|
||||
Use: "auth-api",
|
||||
Short: "OpenCloud authentication API for external services",
|
||||
})
|
||||
app.AddCommand(GetCommands(cfg)...)
|
||||
app.SetArgs(os.Args[1:])
|
||||
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
return app.ExecuteContext(cfg.Context)
|
||||
}
|
||||
|
||||
@@ -13,24 +13,24 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/services/auth-api/pkg/metrics"
|
||||
"github.com/opencloud-eu/opencloud/services/auth-api/pkg/server/debug"
|
||||
"github.com/opencloud-eu/opencloud/services/auth-api/pkg/server/http"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Server is the entrypoint for the server command.
|
||||
func Server(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "server",
|
||||
Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
|
||||
Category: "server",
|
||||
Before: func(_ *cli.Context) error {
|
||||
func Server(cfg *config.Config) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "server",
|
||||
Short: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
return configlog.ReturnFatal(parser.ParseConfig(cfg))
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
ctx, cancel = context.WithCancel(context.Background())
|
||||
m = metrics.New()
|
||||
)
|
||||
|
||||
|
||||
@@ -6,16 +6,15 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/pkg/version"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/services/auth-api/pkg/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Version prints the service versions of all running instances.
|
||||
func Version(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "version",
|
||||
Usage: "print the version of this binary and the running service instances",
|
||||
Category: "info",
|
||||
Action: func(c *cli.Context) error {
|
||||
func Version(cfg *config.Config) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "print the version of this binary and the running service instances",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("Version: " + version.GetString())
|
||||
fmt.Printf("Compiled: %s\n", version.Compiled())
|
||||
fmt.Println("")
|
||||
|
||||
@@ -5,23 +5,30 @@ import (
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/clihelper"
|
||||
"github.com/opencloud-eu/opencloud/services/groupware/pkg/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// GetCommands provides all commands for this service
|
||||
func GetCommands(cfg *config.Config) cli.Commands {
|
||||
return []*cli.Command{
|
||||
func GetCommands(cfg *config.Config) []*cobra.Command {
|
||||
return []*cobra.Command{
|
||||
// start this service
|
||||
Server(cfg),
|
||||
|
||||
// infos about this service
|
||||
// Health(cfg),
|
||||
Version(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
// Execute is the entry point for the opencloud group command.
|
||||
func Execute(cfg *config.Config) error {
|
||||
app := clihelper.DefaultApp(&cli.App{
|
||||
Name: "groupware",
|
||||
Usage: "Groupware service for OpenCloud",
|
||||
Commands: GetCommands(cfg),
|
||||
app := clihelper.DefaultApp(&cobra.Command{
|
||||
Use: "groupware",
|
||||
Short: "Groupware service for OpenCloud",
|
||||
})
|
||||
app.AddCommand(GetCommands(cfg)...)
|
||||
app.SetArgs(os.Args[1:])
|
||||
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
return app.ExecuteContext(cfg.Context)
|
||||
}
|
||||
|
||||
@@ -12,24 +12,24 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/services/groupware/pkg/metrics"
|
||||
"github.com/opencloud-eu/opencloud/services/groupware/pkg/server/debug"
|
||||
"github.com/opencloud-eu/opencloud/services/groupware/pkg/server/http"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Server is the entrypoint for the server command.
|
||||
func Server(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "server",
|
||||
Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
|
||||
Category: "server",
|
||||
Before: func(_ *cli.Context) error {
|
||||
func Server(cfg *config.Config) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "server",
|
||||
Short: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
return configlog.ReturnFatal(parser.ParseConfig(cfg))
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
ctx, cancel = context.WithCancel(context.Background())
|
||||
m = metrics.NewHttpMetrics()
|
||||
)
|
||||
|
||||
|
||||
@@ -6,16 +6,15 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/pkg/version"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/services/groupware/pkg/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Version prints the service versions of all running instances.
|
||||
func Version(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "version",
|
||||
Usage: "print the version of this binary and the running service instances",
|
||||
Category: "info",
|
||||
Action: func(c *cli.Context) error {
|
||||
func Version(cfg *config.Config) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "print the version of this binary and the running service instances",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("Version: " + version.GetString())
|
||||
fmt.Printf("Compiled: %s\n", version.Compiled())
|
||||
fmt.Println("")
|
||||
|
||||
Reference in New Issue
Block a user