[#728][#650][#425] DOC update README example to use execute method

This commit is contained in:
Remko Popma
2019-06-16 22:44:16 +09:00
parent 5ab1a99ab1
commit dc92cbcabf

View File

@@ -136,7 +136,7 @@ import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import java.io.File;
@Command(name = "example", mixinStandardHelpOptions = true, version = "Picocli example 3.0")
@Command(name = "example", mixinStandardHelpOptions = true, version = "Picocli example 4.0")
public class Example implements Runnable {
@Option(names = { "-v", "--verbose" }, description = "Verbose mode. Helpful for troubleshooting. " +
"Multiple -v options increase the verbosity.")
@@ -157,7 +157,11 @@ public class Example implements Runnable {
}
public static void main(String[] args) {
CommandLine.run(new Example(), args);
// By implementing Runnable or Callable, parsing, error handling and handling user
// requests for usage help or version help can be done with one line of code.
int exitCode = new CommandLine(new Example()).execute(args);
System.exit(exitCode);
}
}
```