Skip to main content
9 events
when toggle format what by license comment
Nov 28, 2013 at 5:15 vote accept FlintZA
Nov 28, 2013 at 5:15 comment added FlintZA Yup, was just waiting to see if any other interesting answers came along. Accepting yours based on KISS, which is what swayed me towards the (non-nested) switch.
Nov 27, 2013 at 6:27 comment added FlintZA IEqualityComparer was to specifiy how the dictionary in the parser implementation compares keys. An internal class would be better, but again that was to get a quick proof of concept out. The parser does have anti-KISS smell to it, which is why I was concerned. Looking at it again, the switch also doesn't really need to be nested since there is really no shared logic between the different subcommands, so I could just be switching on split[0]+split[2] and having a method per subcommand, which is what I'll probably go with.
Nov 27, 2013 at 6:17 comment added Mathieu Guindon It is. I see a need for some IParser.Parse(string); the rest is implementation details, and that's where it gets interesting. I might review this code more thoroughly at a later time; I'll let you know if I edit this answer :)
Nov 27, 2013 at 6:03 comment added FlintZA I did actually look at a couple of commandline parser libraries, but in general the syntax they supported didn't quite map to the one we have to deal with. The custom parser seemed like a decent halfway point.
Nov 27, 2013 at 4:45 comment added James Khoury I'd decide by the rule of three.
Nov 27, 2013 at 4:44 comment added Mathieu Guindon Never used one myself, so I can't quite recommend any. It could be overkill, I'd probably go with the dictionary.
Nov 27, 2013 at 4:42 comment added James Khoury What command line parser library would you suggest?
Nov 26, 2013 at 21:37 history answered Mathieu Guindon CC BY-SA 3.0