From f5d3da654cd9afa544d10c3dbaa4fa5a43acfbab Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Fri, 7 Apr 2017 15:23:13 -0700 Subject: [PATCH] Document recommendations for command-line parsing. --- CONTRIBUTING.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e05e4e33fb..505e10d92fb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -125,4 +125,14 @@ uses the common Checkstyle configuration. This is just used for testing. The sample should build without a parent defined. +### Parsing Command-Line Arguments in Samples + +Simple command-line samples with only positional arguments should use the +`args` argument to `main(String... args)` directly. A command-line sample +which has optional parameters should use the [Apache Commons +CLI](https://commons.apache.org/proper/commons-cli/index.html) library. + +Dataflow samples are an exception to this rule, since Dataflow has [its own +method for setting custom +options](https://cloud.google.com/dataflow/pipelines/specifying-exec-params)