MARLEY (Model of Argon Reaction Low Energy Yields)
v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
src
app
cmd_help.cc
1
4
//
5
// This file is part of MARLEY (Model of Argon Reaction Low Energy Yields)
6
//
7
// MARLEY is free software: you can redistribute it and/or modify it under the
8
// terms of version 3 of the GNU General Public License as published by the
9
// Free Software Foundation.
10
//
11
// For the full text of the license please see COPYING or
12
// visit http://opensource.org/licenses/GPL-3.0
13
//
14
// Please respect the MCnet academic usage guidelines. See GUIDELINES
15
// or visit https://www.montecarlonet.org/GUIDELINES for details.
16
17
// Standard library includes
18
#include <iostream>
19
#include <string>
20
21
// MARLEY includes
22
#include "marley/CommandHandler.hh"
23
24
bool
marley::CommandHandler::cmd_help
( std::deque< std::string >& args ) {
25
if
( args.empty() ) {
26
marley::CommandHandler::print_top_level_help
();
27
return
true
;
28
}
29
30
if
( args.size() > 1u ) {
31
std::cerr <<
"marley help: too many arguments\n"
;
32
return
false
;
33
}
34
35
// If we've made it here, then the help command has exactly one argument
36
// which corresponds to a command name or the -h/--help options
37
std::string command_name = args.front();
38
39
// These options are considered synonyms of the help command itself
40
if
( command_name ==
"-h"
|| command_name ==
"--help"
) {
41
command_name =
"help"
;
42
}
43
44
auto
cmd_iter =
command_map_
.find( command_name );
45
if
( cmd_iter !=
command_map_
.end() ) {
46
cmd_iter->second.print_help_();
47
return
true
;
48
}
49
50
std::cerr <<
"marley: unknown command '"
<< command_name <<
"'\n"
;
51
std::cerr <<
"Run 'marley help' for a list of available commands.\n"
;
52
return
false
;
53
}
marley::CommandHandler::cmd_help
static bool cmd_help(std::deque< std::string > &args)
Display top-level or command-specific help messages.
Definition
cmd_help.cc:24
marley::CommandHandler::print_top_level_help
static bool print_top_level_help()
Definition
CommandHandler.cc:168
marley::CommandHandler::command_map_
static const CommandMap command_map_
Definition
CommandHandler.hh:136
Generated by
1.13.2