Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit eac5d16

Browse files
authored
Merge pull request #7 from buggerjs/jk-help
Add `help` command
2 parents a368f18 + 09b37a0 commit eac5d16

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

lib/internal/inspect-repl.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,32 @@ const SHORTCUTS = {
4040
run: 'r',
4141
};
4242

43+
const HELP = `
44+
run, restart, r Run the application or reconnect
45+
kill Kill a running application or disconnect
46+
47+
cont, c Resume execution
48+
next, n Continue to next line in current file
49+
step, s Step into, potentially entering a function
50+
out, o Step out, leaving the current function
51+
backtrace, bt Print the current backtrace
52+
list Print the source around the line where execution is currently paused
53+
54+
setBreakpoint, sb Set a breakpoint
55+
clearBreakpoint, cb Clear a breakpoint
56+
breakpoints List all known breakpoints
57+
58+
watch(expr) Start watching the given expression
59+
unwatch(expr) Stop watching an expression
60+
watchers Print all watched expressions and their current values
61+
62+
exec(expr) Evaluate the expression and print the value
63+
repl Enter a debug repl that works like exec
64+
65+
scripts List application scripts that are currently loaded
66+
scripts(true) List all scripts (including node-internals)
67+
`.trim();
68+
4369
function getRelativePath(filename) {
4470
const dir = `${Path.resolve()}/`;
4571

@@ -629,6 +655,10 @@ function createRepl(inspector) {
629655

630656
function initializeContext(context) {
631657
copyOwnProperties(context, {
658+
get help() {
659+
print(HELP);
660+
},
661+
632662
get run() {
633663
return inspector.run();
634664
},

test/cli/help.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
const { test } = require('tap');
3+
4+
const startCLI = require('./start-cli');
5+
6+
test('examples/empty.js', (t) => {
7+
const cli = startCLI(['examples/empty.js']);
8+
9+
function onFatal(error) {
10+
cli.quit();
11+
throw error;
12+
}
13+
14+
return cli.waitFor(/break/)
15+
.then(() => cli.waitForPrompt())
16+
.then(() => cli.command('help'))
17+
.then(() => {
18+
t.match(cli.output, /run, restart, r\s+/m);
19+
})
20+
.then(() => cli.quit())
21+
.then(null, onFatal);
22+
});

0 commit comments

Comments
 (0)