Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle.kts
  • Loading branch information
darvil82 committed Sep 14, 2023
2 parents 5581b11 + 41d1e33 commit 739b3bb
Show file tree
Hide file tree
Showing 121 changed files with 4,318 additions and 1,862 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Deploy Javadoc

on:
workflow_dispatch:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Deploy JavaDoc
uses: MathieuSoysal/Javadoc-publisher.yml@v2.4.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
javadoc-branch: javadoc
java-version: 17
project: gradle
63 changes: 31 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
| <h1>Important!</h1> Before you read the information below, please note that this project is still in development and is not ready for production use. You are free to use it (thank you if you do so), but you should be aware that the project is in a constantly changing state at the moment! |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|



# Lanat

Lanat is a command line argument parser for Java 17 with ease of use and high customization
Expand All @@ -12,39 +7,43 @@ possibilities in mind.
Here is an example of a simple argument parser definition.

```java
@Command.Define
class MyProgram {
@Argument.Define(obligatory = true, positional = true, description = "The name of the user.")
public String name;

@Argument.Define(argType = StringArgumentType.class, description = "The surname of the user.")
public Optional<String> surname;

@Argument.Define(names = {"age", "a"}, description = "The age of the user.", prefix = '+')
public int age = 18;

@InitDef
public static void beforeInit(@NotNull CommandBuildHelper cmdBuildHelper) {
// configure the argument "age" to have an argument type of
// number range and set the range to 1-100
cmdBuildHelper.<NumberRangeArgumentType<Integer>, Integer>getArgument("age")
.withArgType(new NumberRangeArgumentType<>(1, 100))
.onOk(v -> System.out.println("The age is valid!"));
}
}

class Test {
public static void main(String[] args) {
final var myParser = new ArgumentParser("MyProgram") {{
this.addArgument(Argument.create("name", ArgumentType.STRING())
.obligatory()
.positional() // doesn't need the name to be specified
.description("The name of the user.")
);

this.addArgument(Argument.create("surname", ArgumentType.STRING())
.description("The surname of the user.")
);

this.addArgument(Argument.create("age", ArgumentType.INTEGER())
.defaultValue(18)
.description("The age of the user.")
.addNames("a")
.prefixChar(Argument.PrefixChar.PLUS)
);
}};

// example: david +a20
final var parsedArguments = myParser.parseArgs(args);

var myProgram = ArgumentParser.parseFromInto(MyProgram.class, CLInput.from(args));
System.out.printf(
"Welcome %s! You are %d years old.%n",
parsedArguments.get("name").get(), parsedArguments.<Integer>get("age").get()
myProgram.name, myProgram.age
);

// if no surname was specified, we'll assume it is "Lewis". (Don't ask why)
System.out.println(
"The surname of the user is " + parsedArguments.get("surname").undefined("Lewis")
);
// if no surname was specified, we'll show "none" instead
System.out.println("The surname of the user is " + myProgram.surname.orElse("none"));
}
}
```
```

## Documentation

Javadoc documentation for the latest stable version is available [here](https://darvil82.github.io/Lanat/).
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "darvil"
version = "0.0.1-alpha"
version = "0.0.1"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
Expand All @@ -21,8 +21,7 @@ repositories {
}

dependencies {
implementation("org.jetbrains:annotations:23.1.0")
implementation("fade:mirror:0.0.7+develop")
implementation("org.jetbrains:annotations:24.0.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
}
Expand Down
Loading

0 comments on commit 739b3bb

Please sign in to comment.