Arguments Parser

Arguments Parser is a simple java library to parse command line arguments.

License

License

GroupId

GroupId

org.silentsoft
ArtifactId

ArtifactId

arguments-parser
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Arguments Parser
Arguments Parser is a simple java library to parse command line arguments.
Project URL

Project URL

https://github.com/silentsoft/arguments-parser
Source Code Management

Source Code Management

https://github.com/silentsoft/arguments-parser.git

Download arguments-parser

How to add to project

<!-- https://jarcasting.com/artifacts/org.silentsoft/arguments-parser/ -->
<dependency>
    <groupId>org.silentsoft</groupId>
    <artifactId>arguments-parser</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.silentsoft/arguments-parser/
implementation 'org.silentsoft:arguments-parser:1.1.0'
// https://jarcasting.com/artifacts/org.silentsoft/arguments-parser/
implementation ("org.silentsoft:arguments-parser:1.1.0")
'org.silentsoft:arguments-parser:jar:1.1.0'
<dependency org="org.silentsoft" name="arguments-parser" rev="1.1.0">
  <artifact name="arguments-parser" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.silentsoft', module='arguments-parser', version='1.1.0')
)
libraryDependencies += "org.silentsoft" % "arguments-parser" % "1.1.0"
[org.silentsoft/arguments-parser "1.1.0"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.13

Project Modules

There are no modules declared in this project.

Arguments Parser

release Build Status Quality Gate Status Coverage HitCount

Do not parsing main(args) anymore !

Arguments Parser is a simple java library to parse command line arguments.

Supported Formats

  • -a -b
  • -key1=value1 -key2=value2
  • -key1 value1 -key2 value2
  • -key1=value1 value2 -key2=value3 value4
  • -key1 value1 value2 -key2 value3 value4
  • --a --b
  • --key1=value1 --key2=value2
  • --key1 value1 --key2 value2
  • --key1=value1 value2 --key2=value3 value4
  • --key1 value1 value2 --key2 value3 value4

Maven Central

<dependencies>
    <dependency>
        <groupId>org.silentsoft</groupId>
        <artifactId>arguments-parser</artifactId>
        <version>1.1.0</version>
    </dependency>
</dependencies>

Usage

public static void main(String[] args) throws Exception {
    Arguments arguments = ArgumentsParser.parse(args);
}

Advanced Topics

Arguments Validator Usage

public static void main(String[] args) throws Exception {
    ArgumentsValidator validator = (arguments) -> {
        if (arguments.containsKey("-a") && arguments.containsKey("-b")) {
            throw new InvalidArgumentsException("'-a' and '-b' cannot be exists together.");
        }
        
        return true;
    };
    
    Arguments arguments = ArgumentsParser.parse(args, validator);
}

Parsing Options with dash prefix

  • LEAVE_DASH_PREFIX (default)
  • CASE_SENSITIVE_SINGLE_DASH (default)
  • CASE_INSENSITIVE_SINGLE_DASH
  • CASE_SENSITIVE_DOUBLE_DASH
  • CASE_INSENSITIVE_DOUBLE_DASH (default)

Parsing Options without dash prefix

  • REMOVE_DASH_PREFIX
  • CASE_SENSITIVE
  • CASE_INSENSITIVE

Usage

public static void main(String[] args) throws Exception {
    Arguments arguments = ArgumentsParser.parse(args).with(ParsingOptions...);
}

Packaging

$ mvn clean package

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please note we have a CODE_OF_CONDUCT, please follow it in all your interactions with the project.

License

Please refer to LICENSE.

Versions

Version
1.1.0
1.0.0