Skip to content

Commit

Permalink
#156 improved user manual full application example
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Aug 21, 2017
1 parent 84a8c6c commit f724642
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/java/picocli/Demo.java
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ public void testUsageSubCommandCommit() {
@Command(name = "checksum", description = "Prints the checksum (MD5 by default) of a file to STDOUT.")
class CheckSum implements Callable<Void> {

@Option(names = {"-h", "--help"}, usageHelp = true, description = "Show this help message and exit.")
private boolean helpRequested;

@Option(names = {"-a", "--algorithm"}, description = "MD5, SHA-1, SHA-256, ...")
private String algorithm = "MD5";

Expand All @@ -679,6 +682,10 @@ public static void main(String[] args) throws Exception {

@Override
public Void call() throws Exception {
if (helpRequested) {
CommandLine.usage(this, System.err);
return null;
}
byte[] digest = MessageDigest.getInstance(algorithm).digest(readBytes(file));
print(digest, System.out);
return null;
Expand Down

0 comments on commit f724642

Please sign in to comment.