//nolint:dupl package add import ( "fmt" "edge-infra.dev/pkg/edge/api/graph/model" "edge-infra.dev/pkg/edge/edgecli/flagutil" "edge-infra.dev/pkg/lib/cli/rags" ) type CommandMutation struct { CreateOperatorInterventionCommands struct { model.CreateOperatorInterventionCommandResponse } `graphql:"createOperatorInterventionCommands(commands: $commands)"` } func (mut CommandMutation) Errors() []*model.OperatorInterventionErrorResponse { return mut.CreateOperatorInterventionCommands.Errors } type Command struct { // Commands to be added to the db. // Initialized during the cli pkg's flag parse method. commands []string } func (cmd *Command) ShortUsageString() string { return "edgeadmin operatorintervention add command [--command ]" } func (cmd *Command) ShortHelpString() string { return "Add new commands to the database" } func (cmd *Command) LongHelpString() string { return fmt.Sprintf(longHelpSingleFlagFormatString, "command") } func (cmd *Command) Flags() []*rags.Rag { return []*rags.Rag{ { Name: flagutil.OICommand, Usage: "command to be added", Value: &rags.StringSet{ Var: &cmd.commands, }, Required: true, }, } } func (cmd *Command) Variables() map[string]interface{} { var input []model.OperatorInterventionCommandInput for _, command := range cmd.commands { input = append(input, model.OperatorInterventionCommandInput{ Name: command, }) } return map[string]interface{}{ "commands": input, } } func (cmd *Command) Mutation() OperatorInterventionMutation { return &CommandMutation{} } func (cmd *Command) ResponseType() string { output := "Command" if len(cmd.commands) > 1 { output += "s" } return output }