hanahmily commented on pull request #92:
URL: https://github.com/apache/skywalking-cli/pull/92#issuecomment-806388295
After reading relevant cli codes, could we refactor followings
1. Move action functions from `internal/commands` to `pkg/commands`. For
example:
`pkg/commands/metrics/linear/linear-metrics.go`
```go
func Linear(ctx *cli.Context) (api.MetricsValues, Error){
end := ctx.String("end")
start := ctx.String("start")
step := ctx.Generic("step")
metricsName := ctx.String("name")
entity := interceptor.ParseEntity(ctx)
duration := api.Duration{
Start: start,
End: end,
Step: step.(*model.StepEnumValue).Selected,
}
metricsValues, err := metrics.LinearIntValues(ctx,
api.MetricsCondition{
Name: metricsName,
Entity: entity,
}, duration)
if err != nil {
return nil, err
}
return metricsValues, nil
}
```
`internal/commands/metrics/linear/linear-metrics.go`
```go
Action: func(ctx *cli.Context) error {
metricsValues, err := pkglinear.Linear(ctx)
if err != nil {
return err
}
return display.Display(ctx, &displayable.Displayable{Data:
utils.MetricsValuesToMap(duration, metricsValues)})
},
```
The above convention will simplify the usage of CLI API. BTW, the event
relevant API is missing in `pkg`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]