Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds syntax highlighting to the CLI #639

Merged
merged 5 commits into from Jun 21, 2022
Merged

Conversation

johnedquinn
Copy link
Member

@johnedquinn johnedquinn commented Jun 16, 2022

Relevant Issue

None.

Description

  • Adds syntax highlighting using the SqlLexer and SqlParser
  • Highlighting allows all tokens. This is a better revision than the nanorc files (earlier implementation) because we can differentiate between PartiQL and Ion. Ion does not have highlighting at the moment, but the SQLParser helps users identify when they've made a mistake. See the included video below.
  • Adds the ability to use --monochrome or -m on the REPL to avoid using syntax highlighting

Preview below:

partiql-cli-new.mov

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@johnedquinn johnedquinn marked this pull request as ready for review June 16, 2022 16:29
@johnedquinn johnedquinn marked this pull request as draft June 16, 2022 16:30
@johnedquinn johnedquinn marked this pull request as ready for review June 16, 2022 16:56
cli/src/org/partiql/cli/main.kt Show resolved Hide resolved
cli/resources/org/partiql/cli/syntax/PartiQL.nanorc Outdated Show resolved Hide resolved
cli/src/org/partiql/shell/Shell.kt Outdated Show resolved Hide resolved
cli/src/org/partiql/shell/Shell.kt Outdated Show resolved Hide resolved
Copy link
Member

@alancai98 alancai98 left a comment

Choose a reason for hiding this comment

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

Some really nice work here! Syntax highlighting would definitely be a great feature to add for the PartiQL REPL experience.

Left some questions about the syntax highlighting support from JLine (and if we're restricted to just nanorc files) and additional documentation.

cli/src/org/partiql/shell/Shell.kt Show resolved Hide resolved
cli/src/org/partiql/shell/ShellHighlighter.kt Outdated Show resolved Hide resolved
cli/resources/org/partiql/cli/syntax/PartiQL.nanorc Outdated Show resolved Hide resolved
cli/resources/org/partiql/cli/syntax/PartiQL.nanorc Outdated Show resolved Hide resolved
@johnedquinn
Copy link
Member Author

Decided to go ahead and use the SqlLexer and SqlParser instead of the nanorc files because nanorc doesn't allow advanced features such as multiple grammars (hence our inability to differentiate between PartiQL quoted identifiers and Ion strings). Makes the most sense to use our grammar to identify tokens.

I've updated the description with a new video. Later, we can add highlighting for Ion, and this sets us up for that.

@johnedquinn johnedquinn merged commit 10e5046 into main Jun 21, 2022
@johnedquinn johnedquinn deleted the add-syntax-highlighting branch June 21, 2022 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants