-
Notifications
You must be signed in to change notification settings - Fork 0
/
steamcmd.go
46 lines (37 loc) · 946 Bytes
/
steamcmd.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
40
41
42
43
44
45
46
package gosteamcmd
import (
"github.com/jensvandewiel/gosteamcmd/console"
"io"
)
type SteamCMD struct {
// prompts contains all the commands that will be executed.
prompts []*Prompt
Console *console.Console
Stdout io.Writer
}
// New creates a new SteamCMD instance. steamPath can be left empty like "" to use global path If set it uses the custom path
func New(stdout io.Writer, prompts []*Prompt, steamPath string) *SteamCMD {
s := &SteamCMD{
prompts: prompts,
Stdout: stdout,
}
//prepare command
cmd := path(steamPath)
var args []string
for _, prompt := range s.prompts {
args = append(args, "+"+prompt.FullPrompt)
}
args = append(args, "+quit")
s.Console = console.New(cmd, args, s.Stdout)
return s
}
// Run executes the SteamCMD instance.
func (s *SteamCMD) Run() (uint32, error) {
return s.Console.Run()
}
func path(steamPath string) string {
if steamPath != "" {
return steamPath
}
return "steamcmd"
}