ServiceCommand composes a cobra command from the given inputs.
(cfg *config.Config, serviceName string, subCommands []*cobra.Command, f func(*config.Config))
| 262 | |
| 263 | // ServiceCommand composes a cobra command from the given inputs. |
| 264 | func ServiceCommand(cfg *config.Config, serviceName string, subCommands []*cobra.Command, f func(*config.Config)) *cobra.Command { |
| 265 | command := &cobra.Command{ |
| 266 | Use: serviceName, |
| 267 | Short: fmt.Sprintf("%s service commands", serviceName), |
| 268 | GroupID: CommandGroupServices, |
| 269 | PersistentPreRunE: func(cmd *cobra.Command, args []string) error { |
| 270 | configlog.Error(parser.ParseConfig(cfg, true)) |
| 271 | f(cfg) |
| 272 | return nil |
| 273 | }, |
| 274 | } |
| 275 | |
| 276 | command.AddCommand(subCommands...) |
| 277 | |
| 278 | return command |
| 279 | } |
| 280 | |
| 281 | func init() { |
| 282 | for _, c := range serviceCommands { |
no test coverage detected