Closed facekapow closed 9 years ago
@iefserge @kesla Should this be in runtime-shell
? I'm not sure.
Let's move readline logic into separate file, why EventController instead of callback? runCommand needs a callback, right?
Ok, I'll get to work on that. I was also thinking of how to catch output from the command being run and pass it to the callback.
@iefserge Could I make onInput.add
pass an out
parameter to the callback? So that it can be set to runtime.tty.print
when running directly and it could be replaced with a different function in runCommand
?
as an idea, we could introduce stdio object passed to commands as well as shell
setCommand(function(args, stdio, cb) {
stdio.write('enter your name: ');
stdio.readLine(function(status, input) {
// return some status code if user pressed CTRL+C
stdio.write('hello ' + input);
cb();
});
})
And maybe expose IO object constructor to be able to catch input/output.
var myio = new runtime.tty.IO();
myio.onwrite = function(dataWritten) {};
myio.onreadline = function(cb) {};
runtime.shell.runCommand('test', myio, cb)
I'm creating a stdio folder + some commands right now.
@iefserge I created some stdio commands and updated command 1
to use it.
Git refuses to push terminal.js?! Dont know why
@iefserge I was able to add stdio
and move the get
command to a separate file.
@ArielAbreu let's make an IO object a class, and then instantiate global one internally that uses tty functions
@iefserge Right now i'm working on creating capturing IO in runCommand using EventEmmiter + callback.
I think i've got a good (at least functional) IO
and CaptureIO
for runtime.
What is this PR conflicting with? I closed #59, which I thought was the problem, but the conflict continues!
AGH! I'm closing this, copying my work to another folder, deleting this branch, and doing everything again, step by step, until I hit the conflict.
This adds a run commands feature to
runtime.shell
. If you get an error with theargs
parameter, add a space at the beginning of the string. Usage:UPDATE: I just added a
get
function toruntime.tty
, which allows you to get text from the user easily. It returns anEventController
object that you can listen to. Usage: