-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathaccounts.go
40 lines (34 loc) · 1.05 KB
/
accounts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis-accounts/pkg/command"
svcconfig "github.com/owncloud/ocis-accounts/pkg/config"
"github.com/owncloud/ocis-accounts/pkg/flagset"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)
// AccountsCommand is the entrypoint for the accounts command.
func AccountsCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "accounts",
Usage: "Start accounts server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.Accounts),
Action: func(c *cli.Context) error {
accountsCommand := command.Server(configureAccounts(cfg))
if err := accountsCommand.Before(c); err != nil {
return err
}
return cli.HandleAction(accountsCommand.Action, c)
},
}
}
func configureAccounts(cfg *config.Config) *svcconfig.Config {
cfg.Accounts.Log.Level = cfg.Log.Level
cfg.Accounts.Log.Pretty = cfg.Log.Pretty
cfg.Accounts.Log.Color = cfg.Log.Color
return cfg.Accounts
}
func init() {
register.AddCommand(AccountsCommand)
}