Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
/ args Public

An ultra-lightweight command-line arguments parser and annotation-based mapping library for Java

License

Notifications You must be signed in to change notification settings

Anc3vt/args

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Args

An ultra-lightweight command-line arguments parser and annotation-based mapping library for Java.

No magic. No reflection proxies. Just simple, robust, readable code that lets you parse command-line arguments without tears or ceremony.

Features

  • Simple fluent API (Args.from(...).get(...))
  • Support for boolean flags, aliases, default values
  • Positional arguments
  • Annotation-based mapping into POJOs
  • Help message generator from annotations
  • Quote-aware string tokenizer
  • Zero external dependencies
  • 100% pure Java

Quick Start

String[] args = {"--host", "localhost", "--port", "8080", "--debug"};

Args a = Args.from(args);

String host = a.get("--host", String.class);  // "localhost"
int port = a.get("--port", Integer.class);    // 8080
boolean debug = a.has("--debug");             // true

Annotation Binding

public class Opts {
    @ArgOption(names = {"--host", "-h"})
    public String host = "localhost";

    @ArgOption(names = {"--port", "-p"})
    public int port = 8080;

    @ArgOption(names = {"--debug", "-d"}, usage = "Enable debug mode")
    public boolean debug;

    @ArgPositional(index = 0, usage = "Input file")
    public String input;

    @ArgPositional(index = 1, usage = "Output file")
    public String output;
}

String[] argv = {"-h", "127.0.0.1", "input.txt", "output.txt"};
Opts opts = Args.parse(argv, new Opts());

Help Generator

System.out.println(Args.generateHelp(Opts.class, "my-app"));

Output:

Usage: my-app [options] <input> <output>

Options:
  --host, -h    (default: localhost)
  --port, -p    (default: 8080)
  --debug, -d   Enable debug mode

Arguments:
  input         Input file
  output        Output file

Use Cases

  • Writing tiny CLI utilities and tools
  • Testing scripts with custom args
  • Game dev tools (build pipeline, asset packaging)
  • Replacing brittle manual parsing
  • Annotated configuration parsing

License

Apache License 2.0


Built with insomnia, keyboard crumbs, and a deeply questionable relationship with String[] args.

About

An ultra-lightweight command-line arguments parser and annotation-based mapping library for Java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages