Launching external programs from plugins in Windows #3682
Gavin-Holt
started this conversation in
Show and tell
Replies: 1 comment
-
The last two functions you listed ( |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
From the help file (excert below) I can choose from :
All these options wait for a result, blocking any other activity in Micro.
I guess these functions are useful when you need to get output back into Micro.
However, I have had problems just launching a program, without waiting for a return value.
(I have been trying the 1BRC in Lua and wanted to launch my script - it's not fast)
I have tried various invocations of the functions above:
The only way I have found is to use an external Windows specific launcher:
Is there a better way?
Kind Regards Gavin Holt
From the help file:
micro/shell
ExecCommand(name string, arg ...string) (string, error)
: runs anexecutable with the given arguments, and pipes the output (stderr
and stdout) of the executable to an internal buffer, which is
returned as a string, along with a possible error.
RunCommand(input string) (string, error)
: same asExecCommand
,except this uses micro's argument parser to parse the arguments from
the input. For example,
cat 'hello world.txt' file.txt
, will passtwo arguments in the
ExecCommand
argument list (quoting argumentswill preserve spaces).
RunBackgroundShell(input string) (func() string, error)
: returns afunction that will run the given shell command and return its output.
RunInteractiveShell(input string, wait bool, getOutput bool) (string, error)
:temporarily closes micro and runs the given command in the terminal.
If
wait
is true, micro will wait for the user to press enter beforereturning to text editing. If
getOutput
is true, micro will redirectstdout from the command to the returned string.
JobStart(cmd string, onStdout, onStderr, 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 calledwhen 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{}) *exec.Cmd
:same as
JobStart
, except doesn't run the command through the shelland instead takes as inputs the list of arguments. Returns the started
command.
My 1BRC in Lua
Beta Was this translation helpful? Give feedback.
All reactions