You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Just Args for Java [](https://github.com/sigpwned/just-args-java/actions/workflows/tests.yml)[](https://central.sonatype.com/artifact/com.sigpwned/just-args)[](https://javadoc.io/doc/com.sigpwned/just-args)
2
+
3
+
Just Args is a small, simple library for Java that provides command-line argument parsing support and nothing else.
4
+
5
+
## Goals
6
+
7
+
Just Args should...
8
+
9
+
***Parse arguments**. The library parses valid command-line arguments into a structured and useful model.
10
+
***Be very small**. The JAR file is currently less than 10KB compressed, under 25KB uncompressed.
11
+
***Be very simple**. Users only need one method to parse arguments: `JustArgs.parseArgs`.
12
+
***Be flexible**. Supports options, flags, and positional arguments, as well as advanced configurations.
13
+
***Work out of the box**. Designed to handle common argument parsing use cases with minimal configuration.
14
+
15
+
## Non-Goals
16
+
17
+
Just Args should not...
18
+
19
+
***Validate command-line usage**. The library is not a strict validator and assumes you know how your CLI should behave.
20
+
***Provide advanced features**. The library intentionally avoids dependencies, complex argument validation, and advanced frameworks.
21
+
22
+
## Installation
23
+
24
+
Just Args is available in Maven Central. You can add it to your project using the following Maven dependency:
25
+
26
+
```xml
27
+
<dependency>
28
+
<groupId>com.sigpwned</groupId>
29
+
<artifactId>just-args</artifactId>
30
+
<version>0.0.0</version>
31
+
</dependency>
32
+
```
33
+
34
+
Just Args is a single Java file with no dependencies. In a pinch, you can copy-paste it into your project.
***Options**: Arguments with values, e.g., `-k value`, `--key value` or `--key=value`.
71
+
***Flags**: Boolean arguments, e.g., `-f` or `--flag`.
72
+
***Short Flag Batches**: Multiple short flags grouped together, e.g., `-abc` is equivialent to `-a -b -c`
73
+
***Positional Arguments**: Unlabeled arguments.
74
+
***Separator Token `--`**: Marks all subsequent arguments as positional.
75
+
76
+
---
77
+
78
+
## Advanced Usage
79
+
80
+
### Handling Syntax Errors
81
+
82
+
Just Args throws a `JustArgs.IllegalSyntaxException` when it encounters invalid syntax. This is a subclass of `IllegalArgumentException` for simplicity.
83
+
84
+
```java
85
+
try {
86
+
JustArgs.parseArgs(...);
87
+
} catch (JustArgs.IllegalSyntaxException e) {
88
+
System.err.println("Syntax error at index "+ e.getIndex() +": "+ e.getMessage());
89
+
}
90
+
```
91
+
92
+
### Customizing Argument Names
93
+
94
+
You can configure short and long names for options and flags, and assign them to the same logical bucket in the result:
Most libraries are either too large, too complex, or depend on external frameworks. Just Args is small, simple, and dependency-free—perfect for lightweight projects.
111
+
112
+
### What About Error Messages?
113
+
114
+
Just Args focuses on simplicity. Error messages are provided through exceptions, leaving full control to the user.
115
+
116
+
### Can You Add Feature X?
117
+
118
+
Feel free to ask, but probably not. Just Args is intentionally minimal. If you need advanced features, consider a more fully-featured library like Apache Commons CLI or Picocli.
119
+
120
+
---
121
+
122
+
## A Note on Development
123
+
124
+
Just Args was built with simplicity and clarity in mind. The library is intentionally small and avoids external dependencies to make it easy to embed in any project.
0 commit comments