DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
oks_clone_repository.cxx File Reference
#include "oks/kernel.hpp"
#include <string.h>
#include <stdlib.h>
#include <boost/program_options.hpp>
Include dependency graph for oks_clone_repository.cxx:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 18 of file oks_clone_repository.cxx.

19{
20 std::string config_version, user_dir, branch_name;
21 bool verbose = false;
22
23 try
24 {
25 boost::program_options::options_description desc("Clone and checkout oks repository.\n\n"
26 "By default the master branch is checkout. The \"branch\" command line option can be used to specify particular one. A branch will be created, if does not exist yet.\n"
27 "TDAQ_DB_VERSION process environment variable or \"version\" command line option can be used to specify particular version.\n"
28 "The output directory can be specified via command line, otherwise temporal directory will be created and its name will be reported.\n"
29 "If TDAQ_DB_USER_REPOSITORY process environment variable is set, the utility makes no effect.\n\n"
30 "The command line options are");
31
32 std::vector<std::string> app_types_list;
33 std::vector<std::string> segments_list;
34
35 desc.add_options()
36 ("branch,b", boost::program_options::value<std::string>(&branch_name), "checkout or create given branch name")
37 ("version,e", boost::program_options::value<std::string>(&config_version), "oks config version in type:value format, where type is \"hash\", \"date\" or \"tag\"")
38 ("output-directory,o", boost::program_options::value<std::string>(&user_dir), "output directory; if not defined, create temporal")
39 ("verbose,v", "print verbose information")
40 ("help,h", "print help message");
41
42 boost::program_options::variables_map vm;
43 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
44
45 if (vm.count("help"))
46 {
47 std::cout << desc << std::endl;
48 return EXIT_SUCCESS;
49 }
50
51 if (vm.count("verbose"))
52 verbose = true;
53
54 boost::program_options::notify(vm);
55 }
56 catch (std::exception& ex)
57 {
58 std::cerr << "Command line parsing errors occurred:\n" << ex.what() << std::endl;
59 return EXIT_FAILURE;
60 }
61
62 if (!getenv("TDAQ_DB_USER_REPOSITORY"))
63 {
64 if(!user_dir.empty())
65 setenv("TDAQ_DB_USER_REPOSITORY_PATH", user_dir.c_str(), 1);
66
67 OksKernel k(user_dir.empty() && !verbose, verbose, false, true, config_version.empty() ? nullptr : config_version.c_str(), branch_name);
68
69 if (!k.get_user_repository_root().empty())
70 {
71 k.unset_repository_created();
72
73 if (user_dir.empty())
74 std::cout << k.get_user_repository_root() << std::endl;
75 }
76 }
77
78 return EXIT_SUCCESS;
79}
Provides interface to the OKS kernel.
Definition kernel.hpp:577