Skip to content

Instantly share code, notes, and snippets.

@jonpryor
Created September 19, 2012 19:24
Show Gist options
  • Save jonpryor/3751679 to your computer and use it in GitHub Desktop.
Save jonpryor/3751679 to your computer and use it in GitHub Desktop.

How would I do the equivalent of 'in_dir=s' => \@in_dirs from Perl's Getopt::Long, i.e., a case where --in_dir was used multiple times.

Manually, by capturing values in an intermediate list:

var dirs    = new List<string> ();
var options = new OptionSet {
    { "in_dir=", v => dirs.Add (v) },
};
var unmatched = options.Parse(new[]{
    "--in_dir", "A",
    "something", "else",
    "--in_dir=B",
});
// `dirs` contains { "A", "B" }
// `unmatched` contains { "something", "else" }
@mwpowellhtx
Copy link

How would you define a key/value paired option? At least in the version of code I am reviewing, there is key/value paired. What is the value of Key being anything other than System.String? I cannot confirm that, however, as I cannot find your code base anywhere.

I mean besides this:

  // ...
  , {"keyed=", (TKey k, TValue v) => { /* respond to k/v ... */ }}
  // ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment