https://github.com/radarsh/args
A reusable solution for Command Line Arguments Parsing in Java
https://github.com/radarsh/args
Last synced: 12 months ago
JSON representation
A reusable solution for Command Line Arguments Parsing in Java
- Host: GitHub
- URL: https://github.com/radarsh/args
- Owner: radarsh
- License: apache-2.0
- Created: 2014-12-18T21:14:09.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-18T21:18:50.000Z (over 11 years ago)
- Last Synced: 2025-01-15T11:07:12.163Z (over 1 year ago)
- Language: Java
- Homepage: http://www.adarshr.com/args-engine-a-reusable-solution-for-command-line-arguments-parsing-in-java
- Size: 133 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
args
====
A reusable solution for Command Line Arguments Parsing in Java
## Usage
```java
// Initiate the arguments engine.
ArgsEngine engine = new ArgsEngine();
// Configure the switches/options. Use true for valued options.
engine.add("-q", "--quiet");
engine.add("-o", "--redirect-output", true);
engine.add("-h", "--help");
// Perform the parsing. The 'args' is the String[] received by main method.
engine.parse(args);
// Start fetching states of switches.
boolean quiet = engine.getBoolean("-q");
if(engine.getBoolean("-o")) {
// For valued options, use getString.
String redir = engine.getString("-o");
}
// Use getNonOptions to filter out all options.
String[] nonOptions = engine.getNonOptions();
```