debugger: Print error if executing command that requires being connected

pull/22966/head
Ryan Dahl 2010-12-30 10:31:33 -08:00
parent 2a7e7b1c46
commit 9244a64b59
1 changed files with 39 additions and 0 deletions

View File

@ -415,6 +415,7 @@ function restartQuestion (cb) {
});
}
function printScripts () {
var text = '';
for (var id in c.scripts) {
@ -428,6 +429,12 @@ function printScripts () {
}
function printNotConnected () {
console.log("Program not running. Try 'run'.");
term.prompt();
}
function startInterface() {
term = readline.createInterface(process.stdout);
@ -485,18 +492,30 @@ function startInterface() {
term.prompt();
} else if ('version' == cmd) {
if (!c) {
printNotConnected();
return;
}
c.reqVersion(function (v) {
console.log(v);
term.prompt();
});
} else if (/info +breakpoints/.test(cmd)) {
if (!c) {
printNotConnected();
return;
}
c.listbreakpoints(function (res) {
console.log(res);
term.prompt();
});
} else if (/^backtrace/.test(cmd) || /^bt/.test(cmd)) {
if (!c) {
printNotConnected();
return;
}
c.reqBacktrace(function (bt) {
if (/full/.test(cmd)) {
console.log(bt);
@ -514,25 +533,45 @@ function startInterface() {
});
} else if (cmd == 'scripts' || cmd == 'scripts full') {
if (!c) {
printNotConnected();
return;
}
printScripts();
term.prompt();
} else if (/^continue/.test(cmd) || /^c/.test(cmd)) {
if (!c) {
printNotConnected();
return;
}
c.reqContinue(function (res) {
// Wait for break point. (disable raw mode?)
});
} else if (/^next/.test(cmd) || /^n/.test(cmd)) {
if (!c) {
printNotConnected();
return;
}
c.step('next', 1, function (res) {
// Wait for break point. (disable raw mode?)
});
} else if (/^step/.test(cmd) || /^s/.test(cmd)) {
if (!c) {
printNotConnected();
return;
}
c.step('in', 1, function (res) {
// Wait for break point. (disable raw mode?)
});
} else if (/^print/.test(cmd) || /^p/.test(cmd)) {
if (!c) {
printNotConnected();
return;
}
var i = cmd.indexOf(' ');
if (i < 0) {
console.log("print [expression]");