BPM Command Line Interface Tool (bpmcli)¶
Introduction¶
bpmcli
is a command line based debugging tool for interfacing with the bpmd
process from a shell running on the BPM front-end. An expert should be able to use bpmcli
to execute any of the bpmd
control message queue commands and to examine any of the bpmd
shared memory region data structures.
Design¶
Usage¶
$ bpmcli command [options]
Where 'command' is always provided. If the command is missing bpmcli
should display an error and a 'hint' for proper usage.
The user should be able to redirect stdin, stdout as one would expect to with any Unix command-line utility. This means any error messages should go to stderr.
cli.C¶
The entry point (main(..)
) is in cli.C
. The bpmcli
executable has it's own target in Makefile
. Because most of the commands interact in someway with bpmd
, a SharedMemoryClient
and a ControlMQClient
object are instantiated as automatic variables in main(..)
and passed by reference to the CLICommand
. A large if/else structure parses the command argument (argv[1]
) and then calls the run()
method for the appropriate CLICommand
child. The argc
and argv
parameters are passed as arguments to the run()
method to process the command-line options.
CLICommand¶
The architecture of bpmcli
is based on a simple implementation of the GoF Strategy pattern with the CLICommand
class taking the place of the "Strategy". Each command that the user can provide to bpmcli
is implemented as a child of CLICommand
and must override the virtual _run()
and helpShow()
methods. CLICommand
implements a public run()
method that takes in argc
and argv
as parameters and uses the getopt
API to parse command line options. A couple of command line options are parsed by CLICommand
(e.g. -b and -i) but the implementations may provide their own options to getopt
via the virtual _optsGet()
and _optProcess
methods.