Added Argument System
This commit is contained in:
25
README.MD
25
README.MD
@@ -11,6 +11,31 @@ and a wide set of math/number/string/file/reflection helpers.
|
||||
- Command system: command manager, permissions, execution events
|
||||
- Network system: TCP/UDP transport, packet handling, optional TLS, UDP encryption
|
||||
- Utilities: math/number helpers, strings, colors, files, reflection, logging
|
||||
- Argument parsing: register arguments, validate values, run callbacks
|
||||
|
||||
## ArgumentParser
|
||||
Basic usage
|
||||
```java
|
||||
ArgumentParser parser = new ArgumentParser(args);
|
||||
|
||||
Argument verbose = new Argument("verbose", "Enable verbose output", false);
|
||||
verbose.setRun((arg, value) -> System.out.println("Verbose on"));
|
||||
parser.registerArgument(verbose);
|
||||
|
||||
Argument mode = new Argument("mode", "Run mode", true, true, false, List.of("dev", "prod"));
|
||||
mode.setRun((arg, value) -> System.out.println("Mode: " + value.orElse("")));
|
||||
parser.registerArgument(mode);
|
||||
|
||||
parser.runArguments();
|
||||
```
|
||||
|
||||
Value rules
|
||||
- Constructor: `Argument(name, description, required, requireValue, optionalValue, values)`
|
||||
- `requireValue=false` and `optionalValue=false`: argument has no value
|
||||
- `requireValue=true` and `optionalValue=false`: value must be present
|
||||
- `requireValue=false` and `optionalValue=true`: value is optional
|
||||
- `requireValue=true` and `optionalValue=true` is not allowed
|
||||
- If `values` is not empty, the provided value must be in that list
|
||||
|
||||
## License Information
|
||||
GNU General Public License v3.0 (GPLv3)<br />
|
||||
|
||||
Reference in New Issue
Block a user