fw4spl
VersionGenerator/src/main.cpp
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include <stdlib.h>
8 #include <string>
9 #include <iostream>
10 #include <fstream>
11 
12 #include <boost/program_options.hpp>
13 #include <boost/filesystem/path.hpp>
14 
15 #include <fwAtomsPatch/VersionsManager.hpp>
16 
33 int main(int argc, char** argv)
34 {
35  // Declare the supported options.
36  ::boost::program_options::options_description desc("Allowed options");
37  desc.add_options()
38  ("help,h", "produce help message")
39  ("output,o", ::boost::program_options::value< std::string >(), "set output file")
40  ("context,f", ::boost::program_options::value< std::string >(), "set context name")
41  ("version,v", ::boost::program_options::value< std::string >(), "set version name")
42  ;
43 
44  // Manage the options
45  ::boost::program_options::variables_map vm;
46  ::boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
47  ::boost::program_options::notify(vm);
48 
49  if (vm.count("help"))
50  {
51  std::cout << desc << "\n";
52  return EXIT_SUCCESS;
53  }
54  else if(!vm.count("context"))
55  {
56  std::cout << "You must specify a context name." << "\n";
57  return EXIT_FAILURE;
58  }
59  else if(!vm.count("version"))
60  {
61  std::cout << "You must specify a version name." << "\n";
62  return EXIT_FAILURE;
63  }
64  else if(!vm.count("output"))
65  {
66  std::cout << "You must specify a output file." << "\n";
67  return EXIT_FAILURE;
68  }
69 
70  // Generate the result
71  ::boost::filesystem::path versionFile(vm["output"].as< std::string >());
72  ::fwAtomsPatch::VersionsManager::generateNewFile(versionFile, vm["context"].as< std::string >(),
73  vm["version"].as< std::string >());
74 
75  return EXIT_SUCCESS;
76 }
77 
static FWATOMSPATCH_API void generateNewFile(const ::boost::filesystem::path &filePath, const std::string &context, const std::string &versionName)
Generates a .versions file with currently known data versions.