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

New Java based Nessie CLI tool + REPL #8348

Merged
merged 11 commits into from
May 7, 2024
Merged

Conversation

snazy
Copy link
Member

@snazy snazy commented Apr 17, 2024

Features & functionalities:

  • SQL-ish syntax.
  • REPL.
  • Built-in online HELP command (and HELP <command> command ;), that also shows the commands' syntaxes in the online help. The same information is also published on the projectnessie.org site.
  • Auto-completion of commands, keywords and reference names (use TAB).
  • Syntax highlighting.
  • Paging of long results - showing a lot of content keys or a long commit log just works like less on your Linux or macOS box.
  • Command history, persisted in your home directory (can be turned off).
  • "Just" run a one or more Nessie REPL commands - pass those as arguments on the command line or as a script.
  • Supports all authentication mechanisms that the Nessie Java supports, including all OAuth2 flows.
  • Relatively small, currently just ~14.5MB.
  • Available commands to manage branches and tags, drop tables and views, manage namespaces, list and show tables & views, merge and help.
  • Contains interactive functionality that content-generator tool and pynessie provide, but not potentially dangerous operations.

It's not based on Quarkus, but "plain" Java 11, allows a smaller uber-jar of 14.5 instead of 18.5MB, also improves startup time a bit.

Also included in this PR:

  • Updates to the web site, syntax docs generated from Grammar.
  • Same help texts used for online help + web site.
  • Blog post.

Uses congocc Grammar and parser/lexer, really quick parsing and no runtime dependencies required. congocc also allows relatively(!) easy integration of command line completion and syntax highlighting.

To try the Nessie CLI tool: ./gradlew :nessie-cli:jar && java -jar cli/cli/build/libs/nessie-cli-0.80.1-SNAPSHOT.jar

@snazy snazy force-pushed the new-cli branch 2 times, most recently from 34dec4e to e723375 Compare April 29, 2024 16:35
@snazy snazy marked this pull request as ready for review April 29, 2024 16:35
cli/grammar/src/main/congocc/nessie/nessie-cli-lexer.ccc Outdated Show resolved Hide resolved
site/in-dev/pynessie.md Show resolved Hide resolved
site/in-dev/cli.md Show resolved Hide resolved
site/in-dev/index-release.md Outdated Show resolved Hide resolved
site/docs/blog/posts/2024-05-new-cli.md Outdated Show resolved Hide resolved
site/docs/blog/posts/2024-05-new-cli.md Show resolved Hide resolved
site/docs/blog/posts/2024-05-new-cli.md Outdated Show resolved Hide resolved
site/docs/blog/posts/2024-05-new-cli.md Outdated Show resolved Hide resolved
site/docs/blog/posts/2024-05-new-cli.md Show resolved Hide resolved
site/docs/blog/posts/2024-05-new-cli.md Outdated Show resolved Hide resolved
@snazy snazy force-pushed the new-cli branch 2 times, most recently from 437427d to 2f7319b Compare May 2, 2024 12:59
private Reference currentReference;
private Terminal terminal;

public Integer exitWithCode() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The method name suggests that System.exit() is going to be called. How about just getExitCode/setExitCode?

CHANGELOG.md Outdated
@@ -8,6 +8,8 @@ as necessary. Empty sections will not end in the release notes.

### Highlights

- New Nessie CLI tool + REPL
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe elaborate a bit.

Comment on lines 37 to 45
private static final AttributedStyle STYLE_COMMAND = DEFAULT.foreground(0, 128, 0);
private static final AttributedStyle STYLE_REF_TYPE = DEFAULT.foreground(0, 128, 128);
private static final AttributedStyle STYLE_KEYWORD = DEFAULT.foreground(128, 128, 0);
private static final AttributedStyle STYLE_INVALID = DEFAULT.foreground(168, 0, 0);
private static final AttributedStyle STYLE_LITERAL = DEFAULT.bold().italic();
Copy link
Contributor

Choose a reason for hiding this comment

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

Easier to grasp:

  private static final AttributedStyle STYLE_COMMAND = DEFAULT.foreground(GREEN);
  private static final AttributedStyle STYLE_REF_TYPE = DEFAULT.foreground(CYAN);
  private static final AttributedStyle STYLE_KEYWORD = DEFAULT.foreground(YELLOW);
  private static final AttributedStyle STYLE_INVALID = DEFAULT.foreground(RED);


// There's no easy, better way :(
// Setting the usage-width to 100 chars so that URLs are not line-wrapped.
System.setProperty("picocli.usage.width", "100");
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried commandLine.setUsageHelpAutoWidth(true);?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm - I'd like to keep it at 100 fixed for now, because the docs-generator uses "--help" as well - and I don't know how that would look like in CI.

adutra
adutra previously approved these changes May 6, 2024
snazy added 11 commits May 7, 2024 09:28
Features & functionalities:

* SQL-ish syntax.
* REPL.
* Built-in online `HELP` command (and `HELP <command>` command ;), that also shows the commands' syntaxes in the online help. The same information is also published on the projectnessie.org site.
* Auto-completion of commands, keywords and reference names (use TAB).
* Syntax highlighting.
* Paging of long results - showing a lot of content keys or a long commit log just works like `less` on your Linux or macOS box.
* Command history, persisted in your home directory (can be turned off).
* "Just" run a one or more Nessie REPL commands - pass those as arguments on the command line or as a script.
* Supports all authentication mechanisms that the Nessie Java supports, including all OAuth2 flows.
* Relatively small, currently just ~14.5MB.
* Available commands to manage branches and tags, drop tables and views, manage namespaces, list and show tables & views, merge and help.
* Contains interactive functionality that content-generator tool and pynessie provide, but not potentially dangerous operations.

It's not based on Quarkus, but "plain" Java 11, allows a smaller uber-jar of 14.5 instead of 18.5MB, also improves startup time a bit.

Also included in this PR:

* Updates to the web site, syntax docs generated from Grammar.
* Same help texts used for online help + web site.
* Blog post.

Uses congocc Grammar and parser/lexer, really quick parsing and no runtime dependencies required. congocc also allows relatively(!) easy integration of command line completion and syntax highlighting.

To try the Nessie CLI tool: `./gradlew :nessie-cli:jar && java -jar cli/cli/build/libs/nessie-cli-0.80.1-SNAPSHOT.jar`
* Replace `IN` with `ON` (`IN` is used to reference a catalog in Nessie Spark SQL extensions)
* Enhance `ON` with optional `BRANCH` or `TAG`
* Enhance `AT` with optional `TIMESTAMP` or `COMMIT`
* Rename `TimestampOrHash` to `TimestampOrCommit`
@snazy
Copy link
Member Author

snazy commented May 7, 2024

Reverted a couple of updates to the web-site in the last added commit, as those would break CI and also confuse users.

@snazy snazy merged commit 2b46130 into projectnessie:main May 7, 2024
16 checks passed
@snazy snazy deleted the new-cli branch May 7, 2024 13:05
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

2 participants