diff --git a/util/types.go b/util/types.go index 9b93bc9..fe3ce61 100644 --- a/util/types.go +++ b/util/types.go @@ -19,3 +19,8 @@ type Variant struct { Type Type `json:"type,omitempty"` Equator string `json:"equator,omitempty"` } + +type Command struct { + Name string + Arguments []string +} diff --git a/util/util.go b/util/util.go new file mode 100644 index 0000000..7b04e07 --- /dev/null +++ b/util/util.go @@ -0,0 +1,34 @@ +package util + +import ( + "bytes" + "io" + "os/exec" +) + +func ReadyCmd() (*io.WriteCloser, func() error, error) { + cmd := exec.Command("powershell", "-NoLogo", "-NoProfile", "-Command", "-") + + var stdout bytes.Buffer + cmd.Stdout = &stdout + cmd.Stderr = &stdout + + stdin, err := cmd.StdinPipe() + if err != nil { + return nil, nil, err + } + + if err := cmd.Start(); err != nil { + return nil, nil, err + } + + return &stdin, func() error { + stdin.Close() + + if err := cmd.Wait(); err != nil { + return err + } + + return nil + }, nil +}