Files
ocis/services/graph-explorer/pkg/command/root.go
T

59 lines
1.3 KiB
Go
Raw Normal View History

2020-01-22 17:49:46 +01:00
package command
import (
2021-03-15 15:17:29 +00:00
"context"
2020-01-22 17:49:46 +01:00
"os"
2022-05-04 14:49:59 +02:00
"github.com/owncloud/ocis/v2/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config"
2022-06-20 16:49:06 +02:00
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
2021-03-15 15:17:29 +00:00
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
2020-01-22 17:49:46 +01:00
)
2022-01-03 13:53:27 +01:00
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
2021-02-04 12:24:11 +01:00
// Execute is the entry point for the graph-explorer command.
2021-03-15 15:17:29 +00:00
func Execute(cfg *config.Config) error {
2022-01-03 13:53:27 +01:00
app := clihelper.DefaultApp(&cli.App{
Name: "graph-explorer",
Usage: "Serve Graph-Explorer for oCIS",
2022-01-03 13:53:27 +01:00
Commands: GetCommands(cfg),
})
2020-01-22 17:49:46 +01:00
return app.Run(os.Args)
}
2021-03-15 15:17:29 +00:00
// SutureService allows for the graph-explorer command to be embedded and supervised by a suture supervisor tree.
type SutureService struct {
cfg *config.Config
}
// NewSutureService creates a new graph-explorer.SutureService
func NewSutureService(cfg *ociscfg.Config) suture.Service {
2022-01-03 17:19:10 +01:00
cfg.GraphExplorer.Commons = cfg.Commons
2021-03-15 15:17:29 +00:00
return SutureService{
cfg: cfg.GraphExplorer,
}
}
func (s SutureService) Serve(ctx context.Context) error {
s.cfg.Context = ctx
if err := Execute(s.cfg); err != nil {
return err
}
return nil
}