Command-Line and Options


Your programs should be parameterized and should take inputs at the command line (not prompt the user for inputs!)

The command line can be used to control the behavior of the program:

  • Specify the sort order
  • Specify the algorithm
  • Provide debug/progress information
  • Specify output formats and destination

To specify inputs:

  • From a file v. generate internally
  • Provide the search key if searching

This helps when you want to benchmark or generate performance data – easy to put into a script and push the button.

Figure out once how to process command-line options, and you can just use this for all your programs. Most languages have existing libraries or packages that do pretty sophisticated parsing and fancy stuff like how you specify flags and options. Experiment with these!

, ,

Leave a Reply

Your email address will not be published.