simplify commands and version handling

This commit is contained in:
Willy Kloucek
2022-01-03 13:53:27 +01:00
parent eee0d0c4c8
commit e0656daaa0
41 changed files with 437 additions and 499 deletions
+26 -34
View File
@@ -3,58 +3,50 @@ package command
import (
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/version"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
Frontend(cfg),
Gateway(cfg),
Users(cfg),
Groups(cfg),
AppProvider(cfg),
AuthBasic(cfg),
AuthBearer(cfg),
AuthMachine(cfg),
Sharing(cfg),
StorageHome(cfg),
StorageUsers(cfg),
StoragePublicLink(cfg),
StorageMetadata(cfg),
Health(cfg),
}
}
// Execute is the entry point for the storage command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "storage",
Version: version.String,
Usage: "Storage service for oCIS",
Compiled: version.Compiled(),
app := clihelper.DefaultApp(&cli.App{
Name: "storage",
Usage: "Storage service for oCIS",
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage")
},
Commands: []*cli.Command{
Frontend(cfg),
Gateway(cfg),
Users(cfg),
Groups(cfg),
AppProvider(cfg),
AuthBasic(cfg),
AuthBearer(cfg),
AuthMachine(cfg),
Sharing(cfg),
StorageHome(cfg),
StorageUsers(cfg),
StoragePublicLink(cfg),
StorageMetadata(cfg),
Health(cfg),
},
}
Commands: GetCommands(cfg),
})
cli.HelpFlag = &cli.BoolFlag{
Name: "help,h",
Usage: "Show the help",
}
cli.VersionFlag = &cli.BoolFlag{
Name: "version,v",
Usage: "Print the version",
}
return app.Run(os.Args)
}