Lanat
A command line argument parser for Java 17 with ease of use and high customization possibilities in mind.
Install / Use
/learn @darvil82/LanatREADME
Example
-
First, we define our Command by creating a Command Template.
@Command.Define class MyProgram extends CommandTemplate { @Argument.Define(required = true, positional = true, description = "The name of the user.") public String name; @Argument.Define(type = String.class, description = "The surname of the user.") public Optional<String> surname; @Argument.Define(names = {"age", "a"}, description = "The age of the user.", prefix = Argument.Prefix.PLUS) public int age = 18; @InitDef public static void beforeInit(@NotNull CommandBuildContext ctx) { // configure the argument "age" to have an argument type of // number range and set the range to 18-100 ctx.argWithType("age", new NumberRangeArgumentType<>(18, 100)) .onOk(v -> System.out.println("The age is valid!")); } } -
Then, let that class definition also serve as the container for the parsed values.
public static void main(String[] args) { // example: david +a20 var myProgram = ArgumentParser.parseFromInto(MyProgram.class, args); System.out.printf( "Welcome %s! You are %d years old.%n", myProgram.name, myProgram.age ); // if no surname was specified, we'll show "none" instead System.out.printf("The surname of the user is %s.%n", myProgram.surname.orElse("none")); }
Documentation
Check out the website for more information.
Click here to get started with Lanat, and to check out the full documentation of the latest stable version.
Javadocs for the latest stable version are available online hosted on APIdia and on GitHub pages.
Installation
The package is currently available on Maven Central.
Add the following to your dependencies block:
implementation("io.github.darvil82:lanat:+")
[!NOTE] The
+symbol is a wildcard that will automatically use the latest version of the package. You can also specify a specific version.
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
