Class that implements command pattern. More...
#include <command-line-interface.hpp>
Public Types | |
typedef std::function< void(const Args &argv)> | ExecutorCallback |
typedef std::vector< ArgSpec > | ArgsSpec |
Public Member Functions | |
CommandLineInterface () | |
Dummy constructor (for stl usage) More... | |
CommandLineInterface (const ExecutorCallback &executorCallback, const std::string &name, const std::string &description, const unsigned int &availability, const ArgsSpec &argsSpec) | |
Construct command. More... | |
const std::string & | getName () const |
Get the command name. More... | |
const std::string & | getDescription () const |
Get the command description. More... | |
void | printUsage (std::ostream &out) const |
Print usage to stream. More... | |
bool | isAvailable (unsigned int mode) const |
Check if the command is available in specific mode. More... | |
void | execute (const Args &argv) const |
Do the work. More... | |
const std::vector< std::string > | buildCompletionList (const Args &argv) const |
Static Public Member Functions | |
static void | connect () |
Set the class (static) in a connected state. More... | |
static void | disconnect () |
Disconnect the class from a vasum client. More... | |
static void | executeCallback (const std::function< VsmStatus(VsmClient)> &fun) |
Execute a callback passing the connected VsmClient. More... | |
Private Attributes | |
const ExecutorCallback | mExecutorCallback |
const std::string | mName |
const std::string | mDescription |
const unsigned int | mAvailability |
const ArgsSpec | mArgsSpec |
Static Private Attributes | |
static VsmClient | client = NULL |
Class that implements command pattern.
typedef std::vector<ArgSpec> vasum::cli::CommandLineInterface::ArgsSpec |
typedef std::function<void(const Args& argv)> vasum::cli::CommandLineInterface::ExecutorCallback |
|
inline |
Dummy constructor (for stl usage)
|
inline |
Construct command.
executorCallback | Callback function that will do the job |
name | Command name |
description | Command Description |
availability | Command availability (bit field) |
argsSpec | Description of arguments |
const std::vector< std::string > vasum::cli::CommandLineInterface::buildCompletionList | ( | const Args & | argv | ) | const |
|
static |
Set the class (static) in a connected state.
This persistent connection to the vasum client is required for calls like lock/unlock queue to work.
|
static |
Disconnect the class from a vasum client.
void vasum::cli::CommandLineInterface::execute | ( | const Args & | argv | ) | const |
Do the work.
It calls the callback passed in constructor
argv | Command line arguments |
|
static |
Execute a callback passing the connected VsmClient.
fun | A callback to execute |
const std::string & vasum::cli::CommandLineInterface::getDescription | ( | ) | const |
Get the command description.
const std::string & vasum::cli::CommandLineInterface::getName | ( | ) | const |
Get the command name.
bool vasum::cli::CommandLineInterface::isAvailable | ( | unsigned int | mode | ) | const |
Check if the command is available in specific mode.
mode | A mode to check the command's availability in |
void vasum::cli::CommandLineInterface::printUsage | ( | std::ostream & | out | ) | const |
Print usage to stream.
out | Output stream |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |