-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.go
More file actions
44 lines (34 loc) · 740 Bytes
/
shell.go
File metadata and controls
44 lines (34 loc) · 740 Bytes
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
40
41
42
43
44
package ku
import (
"os"
"strings"
"github.com/mgenware/j9/v3"
)
type Shell struct {
Args *CLIArgs
Tunnel *j9.Tunnel
}
func NewShell(tunnel *j9.Tunnel, args *CLIArgs) *Shell {
return &Shell{Tunnel: tunnel, Args: args}
}
func (s *Shell) Shell(cmd string) string {
output := s.Tunnel.Shell(&j9.ShellOpt{
Cmd: cmd})
return strings.TrimSpace(string(output))
}
func (s *Shell) Spawn(opt *j9.SpawnOpt) {
s.Tunnel.Spawn(opt)
}
func (s *Shell) SpawnRaw(opt *j9.SpawnOpt) error {
return s.Tunnel.SpawnRaw(opt)
}
func (s *Shell) Logger() j9.Logger {
return s.Tunnel.Logger()
}
func (s *Shell) CD(dir string) {
s.Tunnel.CD(dir)
}
func (s *Shell) Quit(msg string) {
s.Tunnel.Logger().Log(j9.LogLevelError, msg)
os.Exit(1)
}