The Console library implements a runtime interactive (network) console which allows to configure, control and manipulate a running application in any way. Additionally this library provides support for configuration files and command line parsing which can be used with or without the network console.
There are three parts to the Config/console library: The Config/Console library is built around several components \li The \link node_tree Node tree\endlink represents all configuration options and commands organized in a filesystem like structure. \li \link console_commands Actions\endlink are added to the node tree in the form of command nodes. \li There exist several interfaces to \link console_access access\endlink entries in the node tree: interactive console, reading configuration files etc. The node tree works like a directory structure. Commands are entered into this directory structure and can be called passing arbitrary arguments. Configuration parameters are just commands which set their respective parameter, however the library allows commands to do much more than just that.
The following example shows a \e very short summary on how to integrate the config/console library. See above links for more:
after this registration, we can call the command from the command-line using
$ someServer --mycommand="1 2"
the console can be accessed easily via telnet:
$ telnet localhost 23232 Trying 127.0.0.1... Connected to localhost. Escape character is '^]' xxxx-xx-xx xx:xx:xx.xxxxxx-0000 [NOTICE][senf::console::Server] Registered new client 0xxxxxxx someServer:/# ls mycommand someServer:/# mycommand !! Important message ... someServer:/# exit xxxx-xx-xx xx:xx:xx.xxxxxx-0000 [NOTICE][senf::console::Server] Disposing client 0xxxxxxx Connection closed by foreign host. $
\see \ref console_testserver for a complete example application
There are several ways to access the node tree:
→ see The node tree
The basic idea is, that the console/config library manages a directory structure of parameters and auxiliary commands. Parameters are just commands which set a parameter value so everything is either a directory entry (senf::console::DirectoryNode) or a command (senf::console::CommandNode).
The console/config language does not define, how arguments are passed to the commands, it just tokenizes the input and passes the tokens to the commands which then handle the conversion.
Since parsing the tokens into something usable is quite tedious and error prone, the library implements automatic argument parsing where the argument tokens are automatically parsed depending on argument types. This enables you to register a command taking an integer argument which will be called with an already parsed integer value (or throw a senf::console::SyntaxErrorException if the conversion fails). This will be the most often used command.