Skip to content

Commit

Permalink
fixed README
Browse files Browse the repository at this point in the history
  • Loading branch information
darvil82 committed May 25, 2024
1 parent 3318209 commit 2bbfb42
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## Example
- First, we define our Command by creating a *Command Template*.

```java
@Command.Define
class MyProgram {
Expand All @@ -28,30 +28,39 @@

@Argument.Define(names = {"age", "a"}, description = "The age of the user.", prefix = Argument.Prefix.PLUS)
public int age = 18;
@InitDef
public static void beforeInit(@NotNull CommandBuildContext ctx) {
// configure the argument "age" to have an argument type of
// number range and set the range to 1-100
ctx.argWithType("age", new NumberRangeArgumentType<>(18, 100))
.onOk(v -> System.out.println("The age is valid!"));
}
}
```

- Then, let that class definition also serve as the container for the parsed values.
- Then, let that class definition also serve as the container for the parsed values.

```java
class Test {
public static void main(String[] args) {
// example: david +a20
var myProgram = ArgumentParser.parseFromInto(MyProgram.class, args);

System.out.printf(
"Welcome %s! You are %d years old.%n",
myProgram.name, myProgram.age
);

// if no surname was specified, we'll show "none" instead
System.out.printf("The surname of the user is %s.%n", myProgram.surname.orElse("none"));
}
public static void main(String[] args) {
// example: david +a20
var myProgram = ArgumentParser.parseFromInto(MyProgram.class, args);
System.out.printf(
"Welcome %s! You are %d years old.%n",
myProgram.name, myProgram.age
);

// if no surname was specified, we'll show "none" instead
System.out.printf("The surname of the user is %s.%n", myProgram.surname.orElse("none"));
}
```
```


## Documentation

Check out the [website](https://darvil82.github.io/lanat-web/) for more information.

[Click here](https://darvil82.github.io/lanat-docs/acquire-lanat.html) to get started with Lanat, and to check out the
full documentation of the latest stable version.

Expand Down

0 comments on commit 2bbfb42

Please sign in to comment.