-
Notifications
You must be signed in to change notification settings - Fork 13
/
search.go
37 lines (31 loc) · 928 Bytes
/
search.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
package platforms
import (
"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/logging"
"github.com/ActiveState/cli/internal/output"
"github.com/ActiveState/cli/pkg/platform/authentication"
"github.com/ActiveState/cli/pkg/platform/model"
)
// Search manages the searching execution context.
type Search struct {
out output.Outputer
auth *authentication.Auth
}
// NewSearch prepares a search execution context for use.
func NewSearch(prime primeable) *Search {
return &Search{
out: prime.Output(),
auth: prime.Auth(),
}
}
// Run executes the search behavior.
func (s *Search) Run() error {
logging.Debug("Execute platforms search")
modelPlatforms, err := model.FetchPlatforms()
if err != nil {
return errs.Wrap(err, "Unable to fetch platforms")
}
platforms := makePlatformsFromModelPlatforms(modelPlatforms)
s.out.Print(output.Prepare(platforms, platforms))
return nil
}