mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-18 14:55:38 -04:00
Adding windows support for JobStart()
This commit is contained in:
parent
96f2735075
commit
4658fa2888
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var Jobs chan JobFunction
|
||||
@ -54,7 +55,11 @@ func (f *CallbackFile) Write(data []byte) (int, error) {
|
||||
// JobStart starts a shell command in the background with the given callbacks
|
||||
// It returns an *exec.Cmd as the job id
|
||||
func JobStart(cmd string, onStdout, onStderr, onExit func(string, []interface{}), userargs ...interface{}) *Job {
|
||||
return JobSpawn("sh", []string{"-c", cmd}, onStdout, onStderr, onExit, userargs...)
|
||||
if runtime.GOOS == "windows" {
|
||||
return JobSpawn("cmd", []string{"/v:on", "/c", cmd}, onStdout, onStderr, onExit, userargs...)
|
||||
} else {
|
||||
return JobSpawn("sh", []string{"-c", cmd}, onStdout, onStderr, onExit, userargs...)
|
||||
}
|
||||
}
|
||||
|
||||
// JobSpawn starts a process with args in the background with the given callbacks
|
||||
|
@ -275,10 +275,10 @@ The packages and their contents are listed below (in Go type signatures):
|
||||
onExit func(string, []interface{}), userargs ...interface{})
|
||||
*exec.Cmd`:
|
||||
Starts a background job by running the shell on the given command
|
||||
(using `sh -c`). Three callbacks can be provided which will be called
|
||||
when the command generates stdout, stderr, or exits. The userargs will
|
||||
be passed to the callbacks, along with the output as the first
|
||||
argument of the callback. Returns the started command.
|
||||
(using `sh -c` or `cmd /v:on /c`). Three callbacks can be provided which
|
||||
will be called when the command generates stdout, stderr, or exits.
|
||||
The userargs will be passed to the callbacks, along with the output
|
||||
as the first argument of the callback. Returns the started command.
|
||||
|
||||
- `JobSpawn(cmd string, cmdArgs []string, onStdout, onStderr,
|
||||
onExit func(string, []interface{}), userargs ...interface{})
|
||||
|
Loading…
Reference in New Issue
Block a user