title: Is there an implementation of "getopt" for Delphi?
body: <p>It doesn't get much easier than using getopt() to parse command line parameters in C/C++.</p>
  
  <p>Is there anything similar for Delphi? Or ideally, with the same syntax? I know Delphi supports FindCmdLineSwitch and ParamStr(), but those still require some additional parsing.</p>
  
  <p>I want something that works like getopt() in C. Something that easily allows basic toggle switches, as well as capturing a value after a switch. See below for some example C code to see what I'm talking about:</p>
  
  <pre><code>void print_help()
  {
          printf("usage:\n") ;
          printf("\t\t-i set input file\n") ;
          printf("\t\t-o set output file\n") ;
          printf("\t\t-c set config file\n") ;
          printf("\t\t-h print this help information\n") ;
          printf("\t\t-v print version\n") ;
  }
   char* input_file = NULL ;
          char *query=NULL;
            char opt_char=0;
          while ((opt_char = getopt(argc, argv, "i:q:vh")) != -1)
          {
                  switch(opt_char)
                  {
                          case 'h':
                                  print_help();
                                  exit(-1);
                                  break;
                          case 'v':
                                  print_version() ;
                                  exit(-1) ;
                                  break ;
                          case 'i':
                                  input_file= optarg ;
                                  break ;
                          case 'q':
                                  query= optarg ;
                                  break ;
                          default:
                                  print_help();
                                  exit(-1);
                                  break;
                  }
          }
  </code></pre>