-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathkool_service.go
39 lines (32 loc) · 965 Bytes
/
kool_service.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
38
39
package commands
import (
"kool-dev/kool/core/shell"
)
// KoolService interface holds the contract for a
// general service which implements some bigger chunk
// of logic usually linked to a command.
type KoolService interface {
Execute([]string) error
Shell() shell.Shell
}
// DefaultKoolService holds handlers and functions shared by all
// services, meant to be used on commands when executing the services.
type DefaultKoolService struct {
shell shell.Shell
}
func newDefaultKoolService() *DefaultKoolService {
return &DefaultKoolService{
shell.NewShell(),
}
}
// Shell exposes the attached shell implementation
func (k *DefaultKoolService) Shell() shell.Shell {
return k.shell
}
// Fake changes the internal dependencies (most notably shell)
// to be the fake conterpart of the real implementation.
// Meant for tests only.
func (k *DefaultKoolService) Fake() *DefaultKoolService {
k.shell = &shell.FakeShell{MockIsTerminal: true}
return k
}