souffle  2.0.2-371-g6315b36
Public Member Functions | Data Fields
souffle::profile::Cli Class Reference

#include <Cli.h>

Collaboration diagram for souffle::profile::Cli:
Collaboration graph

Public Member Functions

 Cli (int argc, char *argv[])
 
void parse ()
 

Data Fields

std::map< char, std::string > args
 

Detailed Description

Definition at line 27 of file Cli.h.

Constructor & Destructor Documentation

◆ Cli()

souffle::profile::Cli::Cli ( int  argc,
char *  argv[] 
)
inline

Definition at line 31 of file Cli.h.

31  : args() {
32  int c;
33  option longOptions[1];
34  longOptions[0] = {nullptr, 0, nullptr, 0};
35  while ((c = getopt_long(argc, argv, "c:hj::", longOptions, nullptr)) != EOF) {
36  // An invalid argument was given
37  if (c == '?') {
38  exit(EXIT_FAILURE);
39  }
40  if (optarg != nullptr) {
41  if (*optarg == '=') {
42  args[c] = optarg + 1;
43  } else {
44  args[c] = optarg;
45  }
46  } else {
47  args[c] = c;
48  }
49  }
50  if (optind < argc && args.count('f') == 0) {
51  args['f'] = argv[optind];
52  }
53  }

References args.

Member Function Documentation

◆ parse()

void souffle::profile::Cli::parse ( )
inline

Definition at line 55 of file Cli.h.

55  {
56  if (args.size() == 0) {
57  std::cout << "No arguments provided.\nTry souffle-profile -h for help.\n";
58  exit(EXIT_FAILURE);
59  }
60 
61  if (args.count('h') != 0 || args.count('f') == 0) {
62  std::cout << "Souffle Profiler" << std::endl
63  << "Usage: souffle-profile <log-file> [ -h | -c <command> [options] | -j ]" << std::endl
64  << "<log-file> The log file to profile." << std::endl
65  << "-c <command> Run the given command on the log file, try with "
66  "'-c help' for a list"
67  << std::endl
68  << " of commands." << std::endl
69  << "-j[filename] Generate a GUI (html/js) version of the profiler."
70  << std::endl
71  << " Default filename is profiler_html/[num].html" << std::endl
72  << "-h Print this help message." << std::endl;
73  exit(0);
74  }
75  std::string filename = args['f'];
76 
77  if (args.count('c') != 0) {
78  Tui tui(filename, false, false);
79  for (auto& command : Tools::split(args['c'], ";")) {
80  tui.runCommand(Tools::split(command, " "));
81  }
82  } else if (args.count('j') != 0) {
83  if (args['j'] == "j") {
84  Tui(filename, false, true).outputHtml();
85  } else {
86  Tui(filename, false, true).outputHtml(args['j']);
87  }
88  } else {
89  Tui(filename, true, false).runProf();
90  }
91  }

References args, souffle::profile::Tui::runCommand(), souffle::profile::Tui::runProf(), and souffle::profile::Tools::split().

Referenced by main().

Here is the call graph for this function:

Field Documentation

◆ args

std::map<char, std::string> souffle::profile::Cli::args

Definition at line 29 of file Cli.h.

Referenced by Cli(), and parse().


The documentation for this class was generated from the following file:
souffle::profile::Cli::args
std::map< char, std::string > args
Definition: Cli.h:29
souffle::profile::Tools::split
std::vector< std::string > split(std::string toSplit, std::string delimiter)
split on the delimiter
Definition: StringUtils.h:162