title: Support arbitrary number of related named arguments with Python argparse
body: <p>I'd like to support a command line interface where users can declare an arbitrary number of samples, with one or more input files corresponding to each sample. Something like this:</p>
  
  <pre><code>$ myprogram.py \
        --foo bar \
        --sample1 input1.tsv \
        --sample2 input2a.tsv input2b.tsv input2c.tsv \
        --sample3 input3-filtered.tsv \
        --out output.tsv
  </code></pre>
  
  <p>The idea is that the option keys will match the pattern <code>--sample(\d+)</code>, and each key will consume all subsequent arguments as option values until the next <code>-</code> or <code>--</code> prefixed flag is encountered. For explicitly declared arguments, this is a common use case that the <code>argparse</code> module supports with the <code>nargs='+'</code> option. But since I need to support an arbitrary number of arguments I can't declare them explicitly.</p>
  
  <p>The <code>parse_known_args</code> command will give me access to all user-supplied arguments, but those not explicitly declared will not be grouped into an indexed data structure. For these I would need to carefully examine the argument list, look ahead to see how many of the subsequent values correspond to the current flag, etc. </p>
  
  <p>Is there any way I can parse these options without having to essentially re-implement large parts of an argument parser (almost) from scratch?</p>