Skip to content

Commit 938eea2

Browse files
authored
doc: corrected mistakes in README (#20)
1 parent 490c61a commit 938eea2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ with `-` or `--`.
6060
var cliargs = new CliArgs("path/to/app", args);
6161
var result = cliargs.parse();
6262

63-
if (result.exception() != null) {
63+
if (result.exception() == null) {
6464
var cmd = result.cmd();
6565
cmd.getName(); // "app"
6666
cmd.getArgs(); // ["hoge", "fuga"]
@@ -133,6 +133,8 @@ option is not specified in command line arguments.
133133
`postparser` field is a functional interface which processes option argument(s) after parsing if this field is specified.
134134

135135
```java
136+
import com.github.sttk.cliargs.OptCfg.NamedParam.*;
137+
...
136138
var args = new String[]{"--foo-bar", "hoge", "--baz", "1", "-z=2", "-x", "fuga"};
137139
var cliargs = new CliArgs("path/to/app", args);
138140

@@ -158,7 +160,7 @@ option is not specified in command line arguments.
158160
};
159161

160162
var result = cliargs.parseWith(optCfgs);
161-
if (result.exception() != null) {
163+
if (result.exception() == null) {
162164
var cmd = result.cmd();
163165
cmd.getName(); // "app"
164166
cmd.getArgs(); // ["hoge", "fuga"]
@@ -227,8 +229,8 @@ And `arg` is what to specify a text for an option argument value in help text.
227229
var options = new Options();
228230

229231
var result = cliargs.parseFor(options);
230-
var cmd = result.cmd();
231232
var optCfgs = result.optCfgs();
233+
var cmd = result.cmdOrThrow();
232234

233235
cmd.getName(); // "app"
234236
cmd.getArgs(); // ["hoge", "fuga"]
@@ -365,7 +367,7 @@ And the help text can be generated as follows:
365367
This library supports native build with GraalVM.
366368
However, since it utilizes reflection for the option store object passed to `CliArgs#parseFor`, the reflection configurations for the class of this object need to be specified in `reflect-config.json`. The configuration are as follows:
367369

368-
```
370+
```json
369371
[
370372
{
371373
"name":"pkg.path.to.OptionStore",

0 commit comments

Comments
 (0)