Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fuzzy-mangos-throw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@neo4j-cypher/language-support': patch
---

adding support for the help command
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ RESET: R E S E T;

PLAY: P L A Y;

ACCESSMODE: A C C E S S '-' M O D E;
ACCESSMODE: A C C E S S '-' M O D E;

HELP: H E L P;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ consoleCommand: COLON (
| styleCmd
| playCmd
| accessModeCmd
| helpCmd
);

paramsCmd: PARAM paramsArgs?;
Expand Down Expand Up @@ -55,6 +56,8 @@ accessModeArgs: (readCompletionRule | writeCompletionRule);

accessModeCmd: ACCESSMODE accessModeArgs?;

helpCmd: HELP;
Copy link
Collaborator

@anderson4j anderson4j Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature sugggestion: What do you think about making it :help consoleCmd? and having it so when one specifies a consoleCmd one can get more info only on this command?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a card for this in "needs refinement" for now


// These rules are needed to distinguish cypher <-> commands, for exapmle `USE` and `:use` in autocompletion
listCompletionRule: LIST;

Expand Down
1 change: 1 addition & 0 deletions packages/language-support/src/lexerSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ export const lexerConsoleCmds = [
CypherLexer.RESET,
CypherLexer.PLAY,
CypherLexer.ACCESSMODE,
CypherLexer.HELP,
];

function toTokentypeObject(arr: number[], tokenType: CypherTokenType) {
Expand Down
8 changes: 7 additions & 1 deletion packages/language-support/src/parserWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ export type ParsedCommandNoPosition =
| { type: 'sysinfo' }
| { type: 'style'; operation?: 'reset' }
| { type: 'play' }
| { type: 'access-mode'; operation?: string };
| { type: 'access-mode'; operation?: string }
| { type: 'help' };

export type ParsedCommand = ParsedCommandNoPosition & RuleTokens;

Expand Down Expand Up @@ -759,6 +760,11 @@ function parseToCommand(
}
}

const helpCmd = consoleCmd.helpCmd();
if (helpCmd) {
return { type: 'help', start, stop };
}

return { type: 'parse-error', start, stop };
}
const stopToken = stop ?? tokens.at(-1);
Expand Down
19 changes: 18 additions & 1 deletion packages/language-support/src/tests/consoleCommands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('sanity checks', () => {
expectParsedCommands(':sysinfo', [{ type: 'sysinfo' }]);
expectParsedCommands(':style', [{ type: 'style' }]);
expectParsedCommands(':play', [{ type: 'play' }]);
expectParsedCommands(':help', [{ type: 'help' }]);
});

test('properly highlights simple commands', () => {
Expand Down Expand Up @@ -218,12 +219,28 @@ describe('sanity checks', () => {
tokenType: 'consoleCommand',
},
]);

expect(applySyntaxColouring(':help')).toEqual([
{
length: 1,
position: { line: 0, startCharacter: 0, startOffset: 0 },
token: ':',
tokenType: 'consoleCommand',
},
{
length: 4,
position: { line: 0, startCharacter: 1, startOffset: 1 },
token: 'help',
tokenType: 'consoleCommand',
},
]);
});

test('completes basic console cmds on :', () => {
expect(autocomplete(':', {})).toEqual([
{ kind: 23, label: 'server' },
{ kind: 23, label: 'use' },
{ kind: 23, label: 'help' },
{ kind: 23, label: 'access-mode' },
{ kind: 23, label: 'play' },
{ kind: 23, label: 'style' },
Expand Down Expand Up @@ -270,7 +287,7 @@ describe('sanity checks', () => {
test('handles misspelled or non-existing command', () => {
expectErrorMessage(
':foo',
'Expected any of access-mode, play, style, sysinfo, welcome, disconnect, connect, param, history, clear, server or use',
'Expected any of help, access-mode, play, style, sysinfo, welcome, disconnect, connect, param, history, clear, server or use',
);

expectErrorMessage(':clea', 'Unexpected token. Did you mean clear?');
Expand Down