iash  v0.5
Library to provide a bash-like shell in an application
Command.h
1 /*
2  * Command.h
3  *
4  * Created on: Oct 7, 2016
5  * Author: paul
6  */
7 
8 #ifndef SRC_COMMAND_H_
9 #define SRC_COMMAND_H_
10 
11 #include "UserCommand.h"
12 #include <iostream>
13 #include <string>
14 #include <vector>
15 
16 class iash;
17 
56 class Command {
57 public:
58  //INITIALIZATION ***********************************************************
68  Command();
69  virtual ~Command();
70 
78  void init (iash *parent);
79 
80  //COMMAND INFORMATION RETRIEVAL ********************************************
89  virtual const std::string getName () const = 0;
90 
102  virtual std::vector<std::string> getAliases () const;
103 
114  virtual const std::string getAliasMapping (const std::string &alias) const;
115 
141  virtual int run (const UserCommand *cmd) = 0;
142 
153  virtual void showUsageMessage (std::ostream &os) const;
154 
167  virtual bool validate (const UserCommand *cmd) const;
168 protected:
169  iash *m_parent;
170 };
171 
172 #endif /* SRC_COMMAND_H_ */
virtual const std::string getName() const =0
Returns the name of this Command to be used in iash.
Command()
Creates a new Comamnd instance.
Definition: Command.cpp:13
virtual std::vector< std::string > getAliases() const
Returns all builtin aliases for this Command.
Definition: Command.cpp:26
virtual bool validate(const UserCommand *cmd) const
Validates the command entered by the user.
Definition: Command.cpp:41
virtual int run(const UserCommand *cmd)=0
Called when a command matching the current Command is issued.
The main shell class for iash.
Definition: iash.h:56
Abstract interface for a command registered with the shell.
Definition: Command.h:56
void init(iash *parent)
Sets the shell parent for this Command.
Definition: Command.cpp:21
Used to retain command arguments and the proper input and output streams for a command call...
Definition: UserCommand.h:28
virtual void showUsageMessage(std::ostream &os) const
Prints a usage message to the specified output stream.
Definition: Command.cpp:36
virtual const std::string getAliasMapping(const std::string &alias) const
Converts a given alias for this command into a fully-qualified command string (using the Command&#39;s de...
Definition: Command.cpp:31