ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cli::App Class Reference

#include <App.h>

Public Member Functions

 App (const std::string &name)
 
Appinsert (const std::string &tag, std::unique_ptr< Command > &&command)
 
int run (int argc, const char *const *argv) const
 

Detailed Description

Definition at line 29 of file App.h.

Constructor & Destructor Documentation

◆ App()

cli::App::App ( const std::string &  name)
explicit

Definition at line 25 of file App.cpp.

25 : _name{name}
26{
27 // DO NOTHING
28}

Member Function Documentation

◆ 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
48 const std::string command{argv[0]};
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: