ccommand.cxx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmMakefile.h"
  14. #include "cmSystemTools.h"
  15. void CMakeCommandUsage(const char* program)
  16. {
  17. std::strstream errorStream;
  18. errorStream << "cmake version " << cmMakefile::GetMajorVersion()
  19. << "." << cmMakefile::GetMinorVersion() << "\n";
  20. errorStream << "Usage: " << program << " [command] [arguments ...]\n"
  21. << " Available commands: \n"
  22. << " copy file1 file2 - copy first file to the second one\n"
  23. << " remove file1 file2 ... - remove the file(s)\n";
  24. errorStream << std::ends;
  25. cmSystemTools::Error(errorStream.str());
  26. }
  27. int main(int ac, char** av)
  28. {
  29. std::vector<std::string> args;
  30. for(int i =0; i < ac; ++i)
  31. {
  32. args.push_back(av[i]);
  33. }
  34. if ( args.size() > 1 )
  35. {
  36. if ( args[1] == "copy" && args.size() == 4 )
  37. {
  38. cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str());
  39. return cmSystemTools::GetErrorOccuredFlag();
  40. }
  41. if ( args[1] == "remove" && args.size() > 2 )
  42. {
  43. for ( std::string::size_type cc = 2; cc < args.size(); cc ++ )
  44. {
  45. cmSystemTools::RemoveFile(args[cc].c_str());
  46. }
  47. return 0;
  48. }
  49. }
  50. ::CMakeCommandUsage(args[0].c_str());
  51. return 1;
  52. }