Skip to content

A simple Star Wars CLI tool built with picocli

Notifications You must be signed in to change notification settings

jlengrand/swacli

Repository files navigation

SwaCLI : A simple Star Wars CLI tool

Created using :

This repository contains several small CLIs that aim at demonstrating the various capabilities of picoCLI.

You can find :

  • SwaCLIBasic Not doing anything but showing how picoCLI comes with batteries included
  • SwaCLIOptions A small demonstration on how to use (mutually exclusive) options and arguments
  • SwaCLISubCommands A small demonstration on how to use subcommands
  • SwaCLIPaginate A small demonstration on how to use subcommands and paginate the results. Default command in the sw compilable
  • SwaCLIProgrammatic An example that uses the programmatic API instead of the annotation system.
  • SwaCLISubCommandsTest An example on how to test commandline configurations

All examples are in Kotlin and provide the same rough capabilities (get some facts about characters or planets in Star Wars)

Compiling / Running

$  ./gradlew customFatJar
$ java -cp build/libs/all-in-one-jar-1.0-SNAPSHOT.jar nl.lengrand.swacli.SwaCLIPaginate

or if you're on Mac give a shot to the latest release.

Creating the native image

You'll need to have GraalVM and the native image extension setup on your system :)

$ cd build/libs;native-image --static -jar all-in-one-jar-1.0-SNAPSHOT.jar sw --enable-http --enable-https
# remove static if you're on Mac :)

Why

This is an example CLI that I created as illustration for my JFall 2020 talk

You can check out the slides here.

Source

Author