Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xiyuan-fengyu/javaargs

command line args parse
https://github.com/xiyuan-fengyu/javaargs

args argsparse command-line command-line-args command-line-args-parse java parse

Last synced: about 5 hours ago
JSON representation

command line args parse

Awesome Lists containing this project

README

        

# JavaArgs
command line args parse

**Quick Start**
[src/test/java/QuickStart.java](src/test/java/QuickStart.java)
```java
import com.xiyuan.args.Args;
import com.xiyuan.args.ArgsExp;

public class QuickStart extends Args{

//ArgExp fromat:
//commandName [optionName] [optionName] (optionName) >
//commandName can be empty str
//[optionName] is a optional arg
//[optionName] is a optional arg, if exist, value is true, else false
//(optionName) is a required arg matched by optionName
//> is a required arg matched by the index of args which are not matched by others
@ArgsExp(exp = "start" +
" [-t<10><\\d+>]" +
" [-p]" +
" (-n<\\d+>)" +
"

public static void main(String[] args) {
QuickStart quickStart = new QuickStart();
quickStart.execute("start -t 20 -n 1000 60000");
quickStart.execute("start 80000 -p -n 1000");
}

}
```

output
```
_t = [20], _p = [false], _n = [1000], time = [60000]
_t = [10], _p = [true], _n = [1000], time = [80000]
```

**More example**
[src/test/java/Test.java](src/test/java/Test.java)