Hi *, I’m trying to write a command line application, but I’m somewhat stuck at using Optparse in the “right” way.
This is what I have right now: optpars.ex · GitHub
What is very weird to me is that it appears to me that I have to add a case clause for every possible combination of options I’m going to have on the command line, and that is obviously not right.
Ok, OptionParser.parse/2 does return a tuple of type {parsed, argv, errors}, parsed is a synonym for Keyword.t, so lets take a look at the Keyword-module, which does have a lot of stuff available.
(Discourse did a bad job getting that line number…)
Won’t that expression on line 22 only parse through the options once, although it may work here since OptionParser has :help passed in first (I am unsure, but if the user passes in --from “blah” --help it could cause an issue that way?), it really should be iterated over or, in this case, the Keyword module should be used.