add service package

This commit is contained in:
Robert Kaussow
2019-08-21 16:41:17 +02:00
parent f7b3b4dcbb
commit 6ad779051c
4 changed files with 41 additions and 52 deletions

17
main.go Normal file
View File

@@ -0,0 +1,17 @@
package main
import (
"os"
"github.com/owncloud/reva-phoenix/service"
)
func main() {
revaphoenixCommand := service.NewRevaPhoenixCommand("reva-phoenix")
if err := revaphoenixCommand.Execute(); err != nil {
os.Exit(1)
}
}

View File

Binary file not shown.

View File

@@ -1,52 +0,0 @@
package service
import (
"os"
"path/filepath"
"github.com/spf13/cobra"
)
// func main() {
// revaphoenixCommand, allCommandFns := NewRevaPhoenixCommand()
// basename := filepath.Base(os.Args[0])
// if err := commandFor(basename, revaphoenixCommand, allCommandFns).Execute(); err != nil {
// os.Exit(1)
// }
// }
// NewRevaPhoenixCommand is the entry point for reva-phoenix
func NewRevaPhoenixCommand() (*cobra.Command, []func() *cobra.Command) {
cmd := &cobra.Command{
Use: "reva-phoenix",
Short: "Request a new project",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 0 {
cmd.Help()
os.Exit(1)
}
},
}
return cmd, nil
}
// 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
// }

24
service/service.go Normal file
View File

@@ -0,0 +1,24 @@
package service
import (
"os"
"github.com/spf13/cobra"
)
// NewRevaPhoenixCommand is the entry point for reva-phoenix
func NewRevaPhoenixCommand(name string) (*cobra.Command) {
cmd := &cobra.Command{
Use: name,
Short: "Request a new project",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 0 {
cmd.Help()
os.Exit(1)
}
},
}
return cmd
}