#include <App.h>
|
| App (const std::string &name) |
|
App & | insert (const std::string &tag, std::unique_ptr< Command > &&command) |
|
int | run (int argc, const char *const *argv) const |
|
Definition at line 29 of file App.h.
◆ App()
cli::App::App |
( |
const std::string & |
name | ) |
|
|
explicit |
Definition at line 25 of file App.cpp.
25 : _name{name}
26{
27
28}
◆ insert()
App & cli::App::insert |
( |
const std::string & |
tag, |
|
|
std::unique_ptr< Command > && |
command |
|
) |
| |
Definition at line 30 of file App.cpp.
31{
32 assert(_commands.find(tag) == _commands.end());
33
34 _commands[tag] = std::move(command);
35
36 return (*this);
37}
◆ run()
int cli::App::run |
( |
int |
argc, |
|
|
const char *const * |
argv |
|
) |
| const |
Definition at line 39 of file App.cpp.
40{
41 if (argc < 1)
42 {
43 std::cerr << "ERROR: COMMAND is not provided" << std::endl;
44 usage(std::cerr);
45 return 255;
46 }
47
49
50 auto it = _commands.find(command);
51
52 if (it == _commands.end())
53 {
54 std::cerr <<
"ERROR: '" <<
command <<
"' is not a valid command" << std::endl;
55 usage(std::cerr);
56 return 255;
57 }
58
59 return it->second->run(argc - 1, argv + 1);
60}
The documentation for this class was generated from the following files: