Poco::OSP::Shell

class Command

Library: OSP/Shell
Package: Shell
Header: Poco/OSP/Shell/Command.h

Description

Command defines the interface every shell command must implement.

The interface is quite simple, consisting only of a single member function that subclasses must override.

Inheritance

Known Derived Classes: HelpCommand, OSPCommand, AbstractCommand, LoginCommand, QuitCommand

Member Summary

Member Functions: execute

Enumerations

CommandStatus

STATUS_OK = 0

successful execution

STATUS_USAGE = 1

command line usage error

STATUS_ERROR = 2

command execution error

STATUS_DENIED = 3

bad credentials or insufficient permissions to execute the command

Constructors

Command

Command();

Creates the Command.

Destructor

~Command virtual

virtual ~Command();

Destroys the Command.

Member Functions

execute virtual

virtual int execute(
    Session & session,
    const std::vector < std::string > & args,
    std::ostream & ostr
) = 0;

Execute the command, using the given arguments, within the given session. The first element of the args vector is the command name.

Any output produced by executing the command can be written to the given output stream.

An integer must be returned that denotes success or failure of the command. Upon success, 0 shall be returned. The CommandStatus enumeration defines a few commonly used error codes that should be used. Other statis codes in the range 0 - 99 can be used as well. Negative status codes are reserved for internal use.