Pakman
help.cc
1 #include <string>
2 #include <iostream>
3 
4 #include "master/AbstractMaster.h"
5 #include "controller/AbstractController.h"
6 
7 #include "help.h"
8 
9 std::string usage()
10 {
11  std::string usage_string;
12  usage_string += "Usage: ";
13  usage_string += g_program_name;
14  usage_string += " <master> <controller>";
15  usage_string += " <required args>... [options]...";
16  usage_string += "\n";
17  return usage_string;
18 }
19 
20 std::string general_options()
21 {
22  return R"(General options:
23  -h, --help show help message
24  -i, --ignore-errors ignore nonzero return code from simulator
25  -d, --discard-child-stderr discard stderr from child processes
26  -v, --verbosity=level set verbosity level to debug/info/off
27  (default info)
28  -o, --output-file set output file (default stdout)
29 )";
30 }
31 
32 void overview(int status)
33 {
34  // Print usage
35  std::cout << usage();
36 
37  // Print general options
38  std::cout << std::endl;
39  std::cout << general_options();
40 
41  // Print overview
42  std::cout << std::endl;
43  std::cout <<
44 R"(Available masters:
45  serial run at most one simulation overall
46  mpi run at most one simulation per launched MPI process
47 See ')" << g_program_name << R"( <master> --help' for more info.
48 
49 Available controllers:
50  sweep run a parameter sweep
51  rejection run the ABC rejection algorithm
52  smc run the ABC SMC algorithm
53 See ')" << g_program_name << R"( <controller> --help' for more info.
54 
55 Alternatively, see ')" <<
56 g_program_name << R"( <master> <controller> --help' for more info
57 on both <master> and <controller>.
58 )";
59 
60  // Exit
61  exit(status);
62 }
63 
64 void help(master_t master, controller_t controller, int status)
65 {
66  // Print usage
67  std::cout << usage();
68 
69  // Print general options
70  std::cout << std::endl;
71  std::cout << general_options();
72 
73  // If given valid master, print master help
74  if (master != no_master)
75  {
76  // Leave one line
77  std::cout << std::endl;
78 
79  // Print master help
80  std::cout << AbstractMaster::help(master);
81  }
82 
83  // If given valid controller, print controller help
84  if (controller != no_controller)
85  {
86  // Leave one line
87  std::cout << std::endl;
88 
89  // Print master help
90  std::cout << AbstractController::help(controller);
91  }
92 
93  // Exit
94  exit(status);
95 }
std::string usage()
Definition: help.cc:9
void overview(int status)
Definition: help.cc:32
std::string general_options()
Definition: help.cc:20
controller_t
Definition: common.h:45
static std::string help(controller_t controller)
master_t
Definition: common.h:37
const char * g_program_name
Definition: main.cc:22
void help(master_t master, controller_t controller, int status)
Definition: help.cc:64
static std::string help(master_t master)