<dependency>
<groupId>com.monovore</groupId>
<artifactId>decline-core_2.13</artifactId>
<version>1.3.0</version>
</dependency>
groovy
implementation 'com.monovore:decline-core_2.13:1.3.0'
import com.monovore.decline.Command;
import com.monovore.decline.Opts;
public class StringLengthCounter {
public static void main(String[] args) {
Command<String> command = Command
.command("length", "Count the length of a string.")
.argument(Opts.string("input", "The input string."));
command.parse(args).fold(
error -> {
System.err.println(error);
System.exit(1);
},
input -> {
System.out.println("Input length: " + input.length());
}
);
}
}
shell
java StringLengthCounter "Hello, World!"
Input length: 13