https://github.com/voomdoon/vd-cli-util
https://github.com/voomdoon/vd-cli-util
cli cli-framework command-line-interface java maven option-parsing
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/voomdoon/vd-cli-util
- Owner: voomdoon
- License: apache-2.0
- Created: 2022-03-30T23:00:37.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-12-20T17:17:02.000Z (about 1 month ago)
- Last Synced: 2025-12-22T09:33:02.461Z (about 1 month ago)
- Topics: cli, cli-framework, command-line-interface, java, maven, option-parsing
- Language: Java
- Homepage:
- Size: 119 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vd-cli-util
A lightweight Java framework for building command-line tools with structured option parsing, help generation, and testable execution.
---
## โจ Features
- Structured argument and option parsing
- Auto-generated help output
- Layered error handling
- Fully testable CLI programs (no `System.exit()` in tests)
- Modular design for reusability and extension
---
## ๐ฆ Maven Dependency
```xml
de.voomdoon.util
vd-cli-util
0.2.0-SNAPSHOT
```
---
## ๐ Getting Started
### 1. Extend the `Program` class
```java
public class HelloWorldProgram extends Program {
public static void main(String[] args) {
Program.run(args);
}
private Option nameOption;
protected void initOptions() {
nameOption = addOption().longName("name").hasValue("username").build();
}
protected void run() {
String name = getOptionValue(nameOption).orElse("World");
System.out.println("Hello, " + name + "!");
}
}
```
---
## ๐งช Testing
Use `ProgramTestingUtil` to enable test mode and prevent `System.exit()` during unit tests.
```java
@BeforeEach
void setup() {
ProgramTestingUtil.enableTestingMode();
}
```
---
## ๐ Packages Overview
| Package | Purpose |
|--------|---------|
| `cli` | Main CLI lifecycle (Program, runner, execution) |
| `cli.args` | Option and argument parsing |
| `cli.args.exception` | Argument validation exceptions |
| `cli.testing` | Test support utilities |