Skip to content

Built using Micronaut framework and GraalVM executable. CLI built using picocli library.

Notifications You must be signed in to change notification settings

aymanapatel/java-cli

Repository files navigation

Java CLI

Table Of Contents

🔨 Built using Micronaut framework and GraalVM executable. CLI built using Picocli library.🔨

Gradle GraalVM Micronaut Picocli

Setup (SDKMan and GraalVM)

Description CLI Comamnd
Install GraalVM using sdkman sdk install java 20.1.0.r11-grl
Use GraalVm sdk use java 20.1.0.r11-grl
Install Native Image executable using GraalVM Updater gu install native-image
List GraalVM CLI gu list

Run commands

GraalVM install

Use SDKMan for easy switching between Java Version (among others)

  1. Install GraalVM-specific Java 11 JDK.
  • sdk install java 20.1.0.r11-grl
  1. Use GraalVm's Java 11
  • sdk use java 20.1.0.r11-grl
  1. Install Native Image for native executable JARs
  • gu install native-image
  1. [Check] List images
  • gu list

Build project

./gradlew --no-daemon assemble

  • This builds Shadow JAR of the project.

CLI Commands to check JAR

  • java -jar build/libs/stackoverflow-cli-0.1-all.jar

  • java -jar build/libs/stackoverflow-cli-0.1-all.jar search

  • java -jar build/libs/stackoverflow-cli-0.1-all.jar search -q "merge maps" -t java

  • java -jar build/libs/stackoverflow-cli-0.1-all.jar search -q "merge maps" -t java --verbose

Native Binary creation

native-image --no-server -cp build/libs/stackoverflow-cli-0.1-all.jar

  • Builds the JAR to binary executable, which doesn't require java for executing.

Use command to run the native-executable: ./stackoverflow-cli search -q "merge maps" -t java --verbose

Add Oauth2 for Stack Exchange

API Link: https://api.stackexchange.com/docs/authentication

Register API here: https://stackapps.com/apps/oauth/register

Running only auth package

./gradlew --no-daemon run --args="auth"

Store credentails

Credentials are stored in: ~/.stackoverflow-cli/credentials.properties

Github Issues

  1. Graceful shutdown of Netty Event Loop (Micronaut's HTTP client) takes 2 seconds. micronaut-projects/micronaut-core#3582

About

Built using Micronaut framework and GraalVM executable. CLI built using picocli library.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published