title: Java: Apache commons-cli how to handle options that depend on each other
body: <p>I'm kinda struggling with the Apache commons-cli v1.3 and I haven't found a practical solution to the following problem yet:</p>
  
  <p>I have a command line tool that - depending on the specified parameters - creates a String (or reads it from a local file), possible edits it inline, and optionally displays, writes said String to a local file or sends it via an HTTP request to a server.</p>
  
  <p>So I have the options "c" for "create", "r" for "read", "e" for "edit" (via the cli), "d" for display, "w" for "write", and "p" for "push to server"</p>
  
  <p>Obviously some combinations are possible. E.g. it should be possible to create this String and push it without reading or writing it from/to a file. Also, it should be possible to create and write without pushing, and so on...</p>
  
  <p>So the semantics of the parameters are:</p>
  
  <pre><code>("c" OR ("r" ["e"])) ["d" "w" "p"]
  </code></pre>
  
  <p>Obviously, when the String is "c"reated, it must not be "r"ead. When "c"reating, i'd use interactive input from a cli-parser. When "r"eading, I want to allow the user to "e"dit via interactive input from the cli. The rest of the parameters are kinda optional.</p>
  
  <p>Next: When "r"eading, a filename/path needs to be specified. Also, when "w"riting, this is necessary. Anyhow, it should be possible to specify a file to read from and a SECOND file to write to. So there would be two arguments for filenames, which are both optional.</p>
  
  <p>The resulting syntax would look like this:</p>
  
  <pre><code>tool -cp
  tool -rp "filenametoread"
  tool -rdwp "filenametoread" "filenametowrite"
  tool -cw "filenametowrite"
  </code></pre>
  
  <p>and so on.</p>
  
  <p>I'm a bit lost here. How to I configure commons-cli to have two arguments for filenames, which are required based on the parameters (options) specified? Is this even possible?</p>