OutpostUniverse / OP2Archive

Console Application for examining, creating, and extracting files from Outpost 2 .vol and .clm archives.
https://wiki.outpost2.net/doku.php?id=outpost_2:helper_programs:op2archive
MIT License
1 stars 0 forks source link

Make --HELP bring up help documentation instead of HELP if no initial command is provided #45

Closed Brett208 closed 4 years ago

Brett208 commented 4 years ago

Closes #44

Brett208 commented 4 years ago

I don't use the command line as much as you, so my thought process might be a bit off.

Help is the only switch that is allowed to be invoked before the initial command. For example OP2Archive -D ExtractFolder EXTRACT maps.vol would throw an error because the EXTRACT command must appear before any switches to properly parse.

HELP is the exception to the rest of the switches and is allowed to be parsed in the command slot.

One could check:

// index 0 is for -h, index 1 is for -?
if (consoleSwitches[0].ArgumentMatch(argument) || consoleSwitches[1].ArgumentMatch(argument)) {
   // show help documentation
};

Seemed like a tossup for readability or maintainability to me. Well there is probably a third option I'm not thinking about that is best, but that was the best I could do back when this was originally programmed.

I found writing code that cleanly parses command line arguments and switches and is easy to read very difficult.

DanRStevens commented 4 years ago

Ok, makes sense. Maybe we could swap the order of the if blocks for --Help and LIST then. That would at least make the code a little more uniform.

Brett208 commented 4 years ago

Agreed and a comment indicating it is the only switch supported in the command location