-
Notifications
You must be signed in to change notification settings - Fork 11
/
necocommand.go
31 lines (24 loc) · 961 Bytes
/
necocommand.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
package sss
import (
"context"
"os/exec"
)
// NecoCmdExecutor is interface for the neco command
type NecoCmdExecutor interface {
PowerStop(ctx context.Context, serial string) ([]byte, error)
PowerStatus(ctx context.Context, serial string) ([]byte, error)
TPMClear(ctx context.Context, serial string) ([]byte, error)
}
type necoCmdExecutor struct{}
func newNecoCmdExecutor() necoCmdExecutor {
return necoCmdExecutor{}
}
func (necoCmdExecutor) PowerStop(ctx context.Context, serial string) ([]byte, error) {
return exec.CommandContext(ctx, "neco", "power", "stop", serial).CombinedOutput()
}
func (necoCmdExecutor) PowerStatus(ctx context.Context, serial string) ([]byte, error) {
return exec.CommandContext(ctx, "neco", "power", "status", serial).CombinedOutput()
}
func (necoCmdExecutor) TPMClear(ctx context.Context, serial string) ([]byte, error) {
return exec.CommandContext(ctx, "neco", "tpm", "clear", "--force", serial).CombinedOutput()
}