6 #include "PackageInfo.hh"
17 using std::stringstream;
22 Module(
"CommandLineProcessor"), m_help_flag(0), m_interactive_flag(0), m_version_flag(0) {
33 static struct option long_options[] = {
34 {
"help", no_argument, 0,
'h' },
35 {
"help", no_argument, 0,
'?' },
36 {
"version", no_argument, 0,
'v' },
37 {
"interactive", no_argument, 0,
'n' },
38 {
"macro", required_argument, 0,
'm' },
39 {
"event-file", required_argument, 0,
'i' },
40 {
"lcdd-url", required_argument, 0,
'g' },
41 {
"lcio-file", required_argument, 0,
'o' },
42 {
"lcio-path", required_argument, 0,
'p' },
43 {
"autoname", optional_argument, 0,
'O' },
44 {
"lcio-delete", no_argument, 0,
'x' },
45 {
"run-events", required_argument, 0,
'r' },
46 {
"skip-events", required_argument, 0,
's' },
47 {
"physics-list", required_argument, 0,
'l' },
48 {
"log-file", required_argument, 0,
'L' },
49 {
"seed", required_argument, 0,
'd' },
50 {
"dump-gdml", required_argument, 0,
'G' },
51 {
"optical", no_argument, 0,
'c' },
52 {
"pdg-file", required_argument, 0,
'P' },
53 {
"lcdd-version", required_argument, 0,
'V' },
54 {
"lcdd-setup", required_argument, 0,
'S' },
55 {
"quiet", no_argument, 0,
'q' },
66 c = getopt_long(argc, argv, optstr, long_options, &option_index);
100 string theopt = ostr.str();
142 else if (argc == 2 && optind < argc) {
144 str <<
"/control/execute ";
149 else if (optind == 1 || optind < argc) {
225 "/lcio/fileExists delete"));
269 if (it->first == opt) {
275 assert(cmdlineopt != 0);
281 if (it->second !=
"") {
283 cmdstr += it->second;
372 static const int opt_width = 8;
373 static const int descr_width = 15;
374 static const int name_width = 16;
375 static const int cmd_width = 24;
376 static const int sep_width = 60;
404 for (OptionsList::const_iterator iter =
m_cmds.begin(); iter !=
m_cmds.end(); iter++) {
412 std::string name_str =
"--" + cl_opt->
getLongName();
431 for (OptionsList::const_iterator iter =
m_cmds.begin(); iter !=
m_cmds.end(); iter++) {
432 if ((*iter)->getShortName() == opt) {
441 bool hasoption =
false;
443 if ((*it).first == opt) {
453 for (OptionsList::iterator it =
m_cmds.begin(); it !=
m_cmds.end(); it++) {
Command-line option with a single letter, full name and description plus an associated Geant4 command...
unsigned int getMaxArgs() const
const std::string & getDescription() const
unsigned int getMinArgs() const
const std::string & getLongName() const
const std::string & getShortName() const
const std::string & getG4CommandString() const
CommandLineOption * getCommandLineOption(const std::string &option)
std::string m_getoptOptions
void createOptionsString()
virtual ~CommandLineProcessor()
void processOption(const std::string &option)
CommandLineArguments m_commandline
void process(int argc, char **argv)
void addOption(CommandLineOption *option)
bool hasOption(const std::string &option)
std::pair< std::string, std::string > OptionsPair
void add(const CommandType &command)
ostream & getOutputStream() const
Base class for slic code modules that provides common functionality, such as logging to an output str...