// file: $isip/doc/examples/class/shell/shell_example_00/example.cc
// version: $Id: example.cc 6191 2001-01-16 20:25:40Z duncan $
//

// isip include files
//
#include <CommandLine.h>
#include <Filename.h>
#include <String.h>
#include <File.h>

// main program starts here
//
int main (int argc, const char **argv) {

  // create command line
  //
  CommandLine cmdl;
    
  // set help message
  //
  cmdl.setHelp(
  #include "helpmessage.text"
  );
  
  // parse the command line
  //
  cmdl.parse(argc, argv);
  
  // checks the number of arguments on the command line
  //
  if (cmdl.numArguments() != 3) {
      Console::put(L"you must specify a filename and two strings");
      cmdl.printUsage();
  }
   
  // get file name
  //
  String old_filename;
  cmdl.getArgument(old_filename, 0);

  // get two strings
  //
  String replacethis;
  String replacewith;
  cmdl.getArgument(replacethis, 1);
  cmdl.getArgument(replacewith, 2);
  
  Filename filename;
  filename.assign(old_filename);
  
  // replace the file name
  //
  filename.replace(replacethis, replacewith);

  // changes the filename in the directory
  //
  File file;
  file.rename(old_filename, filename);
  
  // exit gracefully
  //
  Integral::exit();
}
 
