Skip to content

Instantly share code, notes, and snippets.

@romain-grecourt
Created June 5, 2020 22:38
Show Gist options
  • Save romain-grecourt/d5c3ceab8a1f2e3f6cb8ca72d1e4aae0 to your computer and use it in GitHub Desktop.
Save romain-grecourt/d5c3ceab8a1f2e3f6cb8ca72d1e4aae0 to your computer and use it in GitHub Desktop.
Helidon CLI extension

CLI Extension

Separate modules to be forked by the cli to handle things that are too expensive to be bundled with native-image (e.g. "https").

It shall be invoked with java -jar and not require classpath, either self-contained code or a standalone JAR (e.g. shaded).

The JAR file is embedded as a resource in the native CLI binary.

NOTE: Proxy has to be propagated to the forked JVM properly.

Extension JAR check

The JAR file is conditionally extracted into the user directory.

~/.helidon/extension/
              |- version
              |- cli-ext.jar

Both of these files are resources bundled in the native CLI binary.

Commands

update-cache

Takes a version string and populates ~/.helidon/cache.

Supports:

  • version
  • base URL
  • cache location
  • verbosity level

Native CLI code scenario

  • First, check the cache for the need for update.
  • If need to update, check the extension JAR file and set it up
  • Invoke the extension (i.e fork java -jar cli-ext.jar update-cache)

Logging

Log messages are emitted on standard out using the style syntax $(red text), however it does not use the special utility. System.out.println is used and the native-code processes the output from the forked JVM and passes it to the ANSI aware logger.

Error cases

Mainly two kinds of errors:

  • Network error
  • Timeout

We simply EXIT code 0 and 1 to indicate success or failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment