mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-30 08:50:49 -06:00
65 lines
1.3 KiB
Go
65 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/spf13/cobra"
|
|
revaphoenix "github.com/owncloud/reva-phoenix/service"
|
|
)
|
|
|
|
func main() {
|
|
|
|
revahyperCommand, allCommandFns := NewRevaHyperCommand()
|
|
|
|
basename := filepath.Base(os.Args[0])
|
|
if err := commandFor(basename, revahyperCommand, allCommandFns).Execute(); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
// NewRevaHyperCommand is the entry point for reva-hyper
|
|
func NewRevaHyperCommand() (*cobra.Command, []func() *cobra.Command) {
|
|
|
|
apiserver := func() *cobra.Command { return revaphoenix.NewRevaPhoenixCommand("phoenix") }
|
|
|
|
commandFns := []func() *cobra.Command{
|
|
apiserver,
|
|
}
|
|
|
|
|
|
cmd := &cobra.Command{
|
|
Use: "reva-hyper",
|
|
Short: "Manage oCIS stack",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if len(args) != 0 {
|
|
cmd.Help()
|
|
os.Exit(1)
|
|
}
|
|
|
|
},
|
|
}
|
|
|
|
for i := range commandFns {
|
|
cmd.AddCommand(commandFns[i]())
|
|
}
|
|
|
|
return cmd, commandFns
|
|
}
|
|
|
|
func commandFor(basename string, defaultCommand *cobra.Command, commands []func() *cobra.Command) *cobra.Command {
|
|
for _, commandFn := range commands {
|
|
command := commandFn()
|
|
if command.Name() == basename {
|
|
return command
|
|
}
|
|
for _, alias := range command.Aliases {
|
|
if alias == basename {
|
|
return command
|
|
}
|
|
}
|
|
}
|
|
|
|
return defaultCommand
|
|
}
|