Skip to content

Commit 3179732

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 303a346 + ba8f5c0 commit 3179732

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

.github/workflows/maven.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Tests
10+
11+
on:
12+
push:
13+
branches: [ "main" ]
14+
pull_request:
15+
branches: [ "main" ]
16+
17+
jobs:
18+
build:
19+
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Set up JDK 11
25+
uses: actions/setup-java@v3
26+
with:
27+
java-version: '11'
28+
distribution: 'temurin'
29+
cache: maven
30+
- name: Build with Maven
31+
run: mvn -B package --file pom.xml
32+
33+
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
34+
- name: Update dependency graph
35+
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# `sap4j`
2+
A simple Java library for parsing command-line arguments.
3+
4+
### [`how to use`](#how-to-use-it) **|** [`adding to your project`](#adding-sap4j-to-your-project) **|** [`contributing`](#contributing)
5+
6+
### `how to use it`
7+
sap4j is very simple to use. to start, make a `Parser` instance, passing the pattern you want to look for in arguments.
8+
```java
9+
// this parser will use the pattern '--', so it will find arguments starting with '--'.
10+
private static final Parser parser = new Parser("--");
11+
```
12+
next, parse arguments from a String array.
13+
```java
14+
// you can use the 'args' from a 'main' method, for example.
15+
ArgumentList aList = parser.parseArguments(args);
16+
```
17+
now, you can check if an argument is present:
18+
```java
19+
// don't include the pattern your parser uses! just include the name of the argument you're looking for.
20+
boolean hasUsername = aList.argumentIsPresent("username");
21+
```
22+
if it's present, you can get it's value:
23+
```java
24+
// use 'getArgument()' to get an Argument
25+
Argument usernameArg = aList.getArgument("username");
26+
// use this assertion if you've already checked that the argument is present.
27+
assert usernameArg != null;
28+
29+
String username;
30+
// you can use 'hasValue()' to check if an argument has a value. use 'getValue()' to get the String value of an Argument.
31+
if (usernameArg.hasValue()) username = usernameArg.getValue();
32+
else // ... do something else if there's no value
33+
```
34+
35+
### `adding sap4j to your project`
36+
Add the appropriate dependency info to your project:
37+
#### `maven`
38+
Jitpack repository
39+
```xml
40+
<repository>
41+
<id>jitpack.io</id>
42+
<url>https://jitpack.io</url>
43+
</repository>
44+
```
45+
sap4j Dependency
46+
```xml
47+
<dependency>
48+
<groupId>com.github.itstotallyjan</groupId>
49+
<artifactId>sap4j</artifactId>
50+
<version>{VERSION}</version>
51+
</dependency>
52+
```
53+
#### `gradle`
54+
Jitpack Repository
55+
```gradle
56+
repositories {
57+
maven { url 'https://jitpack.io' }
58+
}
59+
```
60+
sap4j Dependency
61+
```gradle
62+
dependencies {
63+
implementation 'com.github.itstotallyjan:sap4j:-SNAPSHOT'
64+
}
65+
```
66+
67+
### `contributing`
68+
Pull requests are accepted! As long as your contribution does not largely change the functionality of the library, I'll probably accept it.

0 commit comments

Comments
 (0)