(The below post is brought to you from years of being irritated by other programmers' quirky command line syntax, and my acknowledgement that for many small apps, doing it "right" can take up way too much time.)
Yes, I'm probably on a bender of posting a bunch of coding philosophy questions. . .
What do you guys think the "standard" format and parsing of command line arguments should be? (When you are writing the program that consumes the arguments)
Should they be strictly parsed (fail if any errors or extra text) or minimally parsed (fail on explicit errors, but ignore extra stuff without failing)?
Should the order of argument be enforced? (Assume the order is irrelevant to processing.)
Allow shortcuts? (E.G. -d or -del instead of forcing -delete to be typed out)
Rigid syntax or lax? (-d only or -d, /d, \d interchangeably)
Error message? What should be included?
Parsing: Are their standard argument parsing code snippets that should be used or just "whatever?" Essentially, are their tools/tricks/patterns to get the most out of the user-friendly vs don't-waste-my-coding-time equation?
NOTE: There is always the inherent dichotomy of "User-friendly" vs. "Is it worth your time to code it for the few users who care" in all of the above.
Yes, I'm probably on a bender of posting a bunch of coding philosophy questions. . .
What do you guys think the "standard" format and parsing of command line arguments should be? (When you are writing the program that consumes the arguments)
Should they be strictly parsed (fail if any errors or extra text) or minimally parsed (fail on explicit errors, but ignore extra stuff without failing)?
Should the order of argument be enforced? (Assume the order is irrelevant to processing.)
Allow shortcuts? (E.G. -d or -del instead of forcing -delete to be typed out)
Rigid syntax or lax? (-d only or -d, /d, \d interchangeably)
Error message? What should be included?
Parsing: Are their standard argument parsing code snippets that should be used or just "whatever?" Essentially, are their tools/tricks/patterns to get the most out of the user-friendly vs don't-waste-my-coding-time equation?
NOTE: There is always the inherent dichotomy of "User-friendly" vs. "Is it worth your time to code it for the few users who care" in all of the above.
