migrate settings from urfave/cli to spf13/cobra

Signed-off-by: Christian Richter <c.richter@opencloud.eu>
This commit is contained in:
Christian Richter
2025-12-02 17:01:27 +01:00
committed by Florian Schade
parent e7a5788634
commit eebced529a
4 changed files with 34 additions and 32 deletions

View File

@@ -5,12 +5,13 @@ import (
"github.com/opencloud-eu/opencloud/pkg/clihelper"
"github.com/opencloud-eu/opencloud/services/settings/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),
@@ -24,11 +25,12 @@ func GetCommands(cfg *config.Config) cli.Commands {
// Execute is the entry point for the opencloud-settings command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultApp(&cli.App{
Name: "settings",
Usage: "Provide settings and permissions for OpenCloud",
Commands: GetCommands(cfg),
app := clihelper.DefaultAppCobra(&cobra.Command{
Use: "settings",
Short: "Provide settings and permissions for OpenCloud",
})
app.AddCommand(GetCommands(cfg)...)
app.SetArgs(os.Args[1:])
return app.RunContext(cfg.Context, os.Args)
return app.ExecuteContext(cfg.Context)
}