mvsim-cli.h
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2024 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/3rdparty/tclap/CmdLine.h>
13 #if defined(MVSIM_HAS_ZMQ) && defined(MVSIM_HAS_PROTOBUF)
14 #include <mvsim/Comms/ports.h>
15 #endif
16 
17 #include <functional>
18 #include <memory>
19 
20 // We need all TCLAP objects to be initialized in order for all translation
21 // units, that is why we use this holder structure:
22 struct cli_flags
23 {
24  TCLAP::CmdLine cmd{"mvsim", ' ', "version", false /* no --help */};
25 
26  TCLAP::UnlabeledMultiArg<std::string> argCmd{
27  "command", "Command to run. Run 'mvsim help' to list commands.", false, "", cmd};
28 
29  TCLAP::ValueArg<std::string> argVerbosity{
30  "v", "verbose", "Verbosity level", false, "INFO", "ERROR|WARN|INFO|DEBUG", cmd};
31 
32  TCLAP::SwitchArg argFullProfiler{
33  "", "full-profiler",
34  "Enable saving *all* timing data, dumping it to a file at the end of "
35  "the "
36  "program.",
37  cmd};
38 
39  TCLAP::SwitchArg argHeadless{"", "headless", "Runs the simulator without any GUI window.", cmd};
40 
41  TCLAP::SwitchArg argDetails{"", "details", "Shows details in the specified subcommand", cmd};
42 
43  TCLAP::SwitchArg argVersion{"", "version", "Shows program version and exits", cmd};
44 
45  TCLAP::SwitchArg argHelp{"h", "help", "Shows more detailed help for command", cmd};
46 
47 #if defined(MVSIM_HAS_ZMQ) && defined(MVSIM_HAS_PROTOBUF)
48  TCLAP::ValueArg<int> argPort{
49  "p", "port", "TCP port to listen at", false, mvsim::MVSIM_PORTNO_MAIN_REP, "TCP port", cmd};
50 #endif
51 
52  TCLAP::ValueArg<double> argRealTimeFactor{
53  "",
54  "realtime-factor",
55  "Realtime modification factor: <1 slower than real-time, >1 faster "
56  "than real-time",
57  false,
58  1.0,
59  "1.0",
60  cmd};
61 };
62 
63 extern std::unique_ptr<cli_flags> cli;
64 
65 using cmd_t = std::function<int(void)>;
66 
67 int printListCommands(); // "help"
68 void printVersion(); // "--version"
69 int launchStandAloneServer(); // "server"
70 int launchSimulation(); // "launch"
71 int commandNode(); // "node"
72 int commandTopic(); // "topic"
73 
76 
77 void commonLaunchServer();
cli
std::unique_ptr< cli_flags > cli
Definition: mvsim-cli-main.cpp:24
commonLaunchServer
void commonLaunchServer()
Definition: mvsim-cli-server.cpp:23
cli_flags::argHelp
TCLAP::SwitchArg argHelp
Definition: mvsim-cli.h:45
launchStandAloneServer
int launchStandAloneServer()
Definition: mvsim-cli-server.cpp:40
cli_flags::argVerbosity
TCLAP::ValueArg< std::string > argVerbosity
Definition: mvsim-cli.h:29
commandTopic
int commandTopic()
Definition: mvsim-cli-topic.cpp:34
cli_flags::argFullProfiler
TCLAP::SwitchArg argFullProfiler
Definition: mvsim-cli.h:32
cli_flags::argVersion
TCLAP::SwitchArg argVersion
Definition: mvsim-cli.h:43
commandNode
int commandNode()
Definition: mvsim-cli-node.cpp:25
printListCommands
int printListCommands()
Definition: mvsim-cli-main.cpp:98
mvsim::MVSIM_PORTNO_MAIN_REP
constexpr unsigned int MVSIM_PORTNO_MAIN_REP
Definition: ports.h:17
launchSimulation
int launchSimulation()
Definition: mvsim-cli-launch.cpp:161
cmd_t
std::function< int(void)> cmd_t
Definition: mvsim-cli.h:65
ports.h
cli_flags::cmd
TCLAP::CmdLine cmd
Definition: mvsim-cli.h:24
cli_flags
Definition: mvsim-cli.h:22
cli_flags::argHeadless
TCLAP::SwitchArg argHeadless
Definition: mvsim-cli.h:39
cli_flags::argCmd
TCLAP::UnlabeledMultiArg< std::string > argCmd
Definition: mvsim-cli.h:26
setConsoleNormalColor
void setConsoleNormalColor()
Definition: mvsim-cli-main.cpp:41
setConsoleErrorColor
void setConsoleErrorColor()
Definition: mvsim-cli-main.cpp:32
printVersion
void printVersion()
Definition: mvsim-cli-main.cpp:107
cli_flags::argRealTimeFactor
TCLAP::ValueArg< double > argRealTimeFactor
Definition: mvsim-cli.h:52
cli_flags::argDetails
TCLAP::SwitchArg argDetails
Definition: mvsim-cli.h:41


mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:08