Execute executes the command
(args []string)
| 93 | |
| 94 | // Execute executes the command |
| 95 | func (c *BaseCommand) Execute(args []string) ExecutionStatus { |
| 96 | log.Tracef("Executing command '"+c.name+"': args: '%v'\n", args) |
| 97 | |
| 98 | flags := flag.NewFlagSet(c.name, flag.ContinueOnError) |
| 99 | flags.SetOutput(io.Discard) |
| 100 | |
| 101 | flags.String(deployServiceURLOpt, "", "") |
| 102 | c.defineCommandOptions(flags) |
| 103 | |
| 104 | parser := NewCommandFlagsParser(flags, c.flagsParser, c.flagsValidator) |
| 105 | err := parser.Parse(args) |
| 106 | if err != nil { |
| 107 | c.Usage(err.Error()) |
| 108 | return Failure |
| 109 | } |
| 110 | |
| 111 | deployServiceUrl, err := c.deployServiceURLCalculator.ComputeDeployServiceURL(GetStringOpt(deployServiceURLOpt, flags)) |
| 112 | if err != nil { |
| 113 | ui.Failed(err.Error()) |
| 114 | return Failure |
| 115 | } |
| 116 | |
| 117 | cfTarget, err := c.GetCFTarget() |
| 118 | if err != nil { |
| 119 | ui.Failed(err.Error()) |
| 120 | return Failure |
| 121 | } |
| 122 | |
| 123 | return c.executeInternal(parser.Args(), deployServiceUrl, flags, cfTarget) |
| 124 | } |
| 125 | |
| 126 | // GetBoolOpt gets the option identified by the specified name. |
| 127 | func GetBoolOpt(name string, flags *flag.FlagSet) bool { |
nothing calls this directly
no test coverage detected