linux - getopt_long vs getopt_long_only -
To make a proper Linux / Unix style application, what is the best option (e.g., Afaik ls Getopt_long, but for example ffmpeg getopt_long_only)
In my opinion, the following are usually things true:
- Users prefer long, natural language options because they are easy to remember.
- Users who wrap scripts in the program, have hundreds of options.
If a program becomes large enough, it will eventually fall out of fewer options combinations that make any kind of emotions compared to the canonical option. For example, -Z may be similar to a long option that starts with a completely different letter. At that point, especially for the single guardian, the option becomes a headache to maintain the parsing code.
If you do, you have a few options:
- Use only long options (usually a bad idea)
- Try to keep your program under 52 options (usually a bad idea)
- Implement the options where small options only become switches that do not take logic , Use long options for those who
- panic among other ways that come Keep the right sense for the cookie
Mix in different places, and you actually start to understand the pain.
When I write a tool that takes a lot of options, the first thing I usually do is to write the code to write the argument, this creates a plan for the flow of the program and a The setting is made. You then work every option.
In other words, if you reach this point that option becomes such an old pain, then it usually indicates a program that quickly develops beyond its planning.
Anyway, to stop the long-running response to me, it is usually better to keep Comet Doop () behavior possible whenever possible. The code obtained from the user is just the cost of doing business, so you should have a complete concern, when possible, get a better user experience.
Comments
Post a Comment