228 const char * prompt = NULL
248 bool runInBackground =
true
261 bool autoDelete =
true,
262 bool runInBackground =
true
267 bool autoDeleteRead =
true,
268 bool autoDeleteWrite =
true,
269 bool runInBackground =
true
340 const char * command,
342 const char * help = NULL,
343 const char * usage = NULL
580 const char * prompt = NULL
591 bool runInBackground =
true
610 const char * prompt = NULL,
611 bool singleThreadForAll =
false
623 bool runInBackground =
true
639 Context * context = NULL
690 const char * prompt = NULL,
691 bool singleThreadForAll =
false
700 #endif // PTLIB_CLI_H
PTCPSocket m_listenSocket
Definition: cli.h:671
void SetHelpOnHelp(const PCaselessString &helpOnHelp)
Set help on help.
Definition: cli.h:465
std::list< Context * > ContextList_t
Definition: cli.h:564
void SetUsername(const PString &username)
Set username for log in validation.
Definition: cli.h:423
void SetHistoryCommand(const PCaselessString &historyCommand)
Set command that will list/execute command history.
Definition: cli.h:485
PCaselessString m_exitCommand
Definition: cli.h:546
void ShowHelp(Context &context)
Show help for registered commands to the context.
virtual ~PCLI()
Destroy the command line interpreter.
PMutex m_contextMutex
Definition: cli.h:566
const PString & GetEditCharacters() const
Get characters used for editing (backspace/delete) command lines.
Definition: cli.h:378
virtual void Stop()
Stop and clean up command line interpreters.
void SetEditCharacters(const PString &editCharacters)
Set characters used for editing (backspace/delete) command lines.
Definition: cli.h:383
PString m_passwordPrompt
Definition: cli.h:543
PString m_newLine
Definition: cli.h:538
PString m_helpOnHelp
Definition: cli.h:548
virtual bool ReadAndProcessInput()
Read a character from the attached channel an process.
Class specialisation for PNotifierTemplate<INT>
PCaselessString m_historyCommand
Definition: cli.h:550
Context & GetContext() const
Get the CLI context supplying the command line arguments.
Definition: cli.h:211
const PString & GetNewLine() const
Get new line string output at the end of every line.
Definition: cli.h:358
PString m_usernamePrompt
Definition: cli.h:542
PThread * m_thread
Definition: cli.h:672
This class is an enhancement to PArgList to add context.
Definition: cli.h:183
virtual bool RunContext(Context *context)
Run a context.
const PCaselessString & GetExitCommand() const
Get command to be used to exit session.
Definition: cli.h:438
const PString & GetPrompt() const
Get prompt used for command line interpreter.
Definition: cli.h:388
virtual Context * AddContext(Context *context=NULL)
Add a command line interpreter context to the system.
virtual bool WritePrompt()
Write prompt (depending on state) to channel.
const PCaselessString & GetHelpCommand() const
Get command to be used to display help.
Definition: cli.h:448
PString m_prompt
Definition: cli.h:541
This is a channel that operates indirectly through another channel(s).
Definition: indchan.h:49
virtual void OnStop()
Callback for when context is stopping.
This class is a variation of a string that ignores case.
Definition: pstring.h:1708
PStringList m_commandHistory
Definition: cli.h:169
virtual void OnReceivedLine(Arguments &line)
Received a completed command line.
PCLIStandard(const char *prompt=NULL)
Create new command line interpreter for standard I/O.
Context(PCLI &cli)
Construct new command line interpreter context.
PString m_username
Definition: cli.h:544
bool IsProcessingCommand() const
Indicate is currently processing a command.
Definition: cli.h:160
void SetCommandErrorPrefix(const PString &commandErrorPrefix)
Set error prefix for if Arguments::WriteError() called.
Definition: cli.h:515
PNotifier m_notifier
Definition: cli.h:557
const PString & GetUnknownCommandError() const
Get error message for if unknown command is entered.
Definition: cli.h:520
virtual bool Start(bool runInBackground=true)
Start a command line interpreter.
bool Start()
Start a command line interpreter thread.
virtual ~Context()
Destroy command line interpreter context.
const PString & GetUsername() const
Get username for log in validation.
Definition: cli.h:418
CommandMap_t m_commands
Definition: cli.h:562
BOOL PBoolean
Definition: object.h:102
virtual void RemoveContext(Context *context)
Remove the command line interpreter context.
bool m_requireEcho
Definition: cli.h:539
const PString & GetHelpOnHelp() const
Get help on help.
Definition: cli.h:459
const PString & GetCommandUsagePrefix() const
Get usage prefix for if Arguments::WriteUsage() called.
Definition: cli.h:500
virtual void GarbageCollection()
Remove any closed command line interpreter contexts.
Context for command line interpreter.
Definition: cli.h:64
void SetUsernamePrompt(const PString &prompt)
Set prompt used for login (if enabled).
Definition: cli.h:403
PString m_noHistoryError
Definition: cli.h:551
bool HandleSingleThreadForAll()
bool m_singleThreadForAll
Definition: cli.h:669
virtual bool Start(bool runInBackground=true)
Start a command line interpreter.
State
Definition: cli.h:172
void SetCommandUsagePrefix(const PString &commandUsagePrefix)
Set usage prefix for if Arguments::WriteUsage() called.
Definition: cli.h:505
bool StartContext(PChannel *channel, bool autoDelete=true, bool runInBackground=true)
Open a command line interpreter context.
std::map< PSocket *, Context * > ContextMap_t
Definition: cli.h:674
void SetNoHistoryError(const PString &noHistoryError)
Set error message for if there is no history.
Definition: cli.h:495
PString m_usage
Definition: cli.h:217
PDECLARE_NOTIFIER(PThread, PCLISocket, ThreadMain)
virtual PTCPSocket * CreateSocket()
const PString & GetPassword() const
Get password for log in validation.
Definition: cli.h:428
Abstract class defining I/O channel semantics.
Definition: channel.h:107
PCLI(const char *prompt=NULL)
Contracut a new command line interpreter.
void SetPasswordPrompt(const PString &prompt)
Set prompt used for password (if enabled).
Definition: cli.h:413
PString m_editCharacters
Definition: cli.h:540
void Broadcast(const PString &message) const
Set a string to all command line interpreter contexts.
PString m_unknownCommandError
Definition: cli.h:554
const PString & GetNoHistoryError() const
Get error message for if there is no history.
Definition: cli.h:490
Command Line Interpreter over standard input/output.
Definition: cli.h:572
virtual bool ProcessInput(int ch)
Process a character read from the channel.
virtual bool Start(bool runInBackground=true)
Start a command line interpreter.
void SetNewLine(const PString &newLine)
Set new line string output at the end of every line.
Definition: cli.h:363
PDECLARE_NOTIFIER(PThread, Context, ThreadMain)
PString m_commandUsagePrefix
Definition: cli.h:552
The character string class.
Definition: pstring.h:108
const PCaselessString & GetRepeatCommand() const
Get the command to be used to repeat the last executed command.
Definition: cli.h:470
PString m_usage
Definition: cli.h:559
void SetPassword(const PString &password)
Set password for log in validation.
Definition: cli.h:433
const PString & GetUsernamePrompt() const
Get prompt used for login (if enabled).
Definition: cli.h:398
Context & WriteError(const PString &error=PString::Empty())
Write an error to the CLI output channel.
A socket that uses the TCP transport on the Internet Protocol.
Definition: tcpsock.h:44
Context & WriteUsage()
Write to the CLI output channel the usage for the current command.
void SetRepeatCommand(const PCaselessString &repeatCommand)
Set the command to be used to repeat the last executed command.
Definition: cli.h:475
PString m_enteredUsername
Definition: cli.h:178
static PString Empty()
Return an empty string.
ContextMap_t m_contextBySocket
Definition: cli.h:675
Context & m_context
Definition: cli.h:215
This class allows the parsing of a set of program arguments.
Definition: args.h:45
PCLI::Context * StartForeground()
Initialise a foreground context and return it.
enum PCLI::Context::State m_state
const PCaselessString & GetHistoryCommand() const
Get command that will list/execute command history.
Definition: cli.h:480
PCaselessString m_repeatCommand
Definition: cli.h:549
PString m_help
Definition: cli.h:558
WORD GetPort() const
Get the port we are listing on.
Definition: cli.h:660
PString m_commandLine
Definition: cli.h:167
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the channel.
bool m_ignoreNextEOL
Definition: cli.h:168
void SetUnknownCommandError(const PString &unknownCommandError)
Set error message for if unknown command is entered.
Definition: cli.h:525
bool GetRequireEcho() const
Get flag for echo is required for entered characters.
Definition: cli.h:368
This class defines a thread of execution in the system.
Definition: thread.h:66
This is a list collection class of PString objects.
Definition: pstring.h:2184
std::map< PString, InternalCommand > CommandMap_t
Definition: cli.h:561
PCLITelnet(WORD port=0, const char *prompt=NULL, bool singleThreadForAll=false)
PCaselessString m_helpCommand
Definition: cli.h:547
bool SetCommand(const char *command, const PNotifier ¬ifier, const char *help=NULL, const char *usage=NULL)
Register a new command to be interpreted.
PCLISocket(WORD port=0, const char *prompt=NULL, bool singleThreadForAll=false)
ContextList_t m_contextList
Definition: cli.h:565
void Stop()
Stop command line interpreter context.
virtual Context * CreateContext()
Create a new context.
virtual void Stop()
Stop and clean up command line interpreters.
PCLI & m_cli
Definition: cli.h:166
Command Line Interpreter over TCP sockets.
Definition: cli.h:603
PThread * m_thread
Definition: cli.h:170
Command Line Interpreter over Telnet sockets.
Definition: cli.h:683
virtual Context * AddContext(Context *context=NULL)
Add a command line interpreter context to the system.
Arguments(Context &context, const PString &rawLine)
virtual void OnStart()
Call back frunction for when context is started.
const PString & GetCommandErrorPrefix() const
Get error prefix for if Arguments::WriteError() called.
Definition: cli.h:510
PString m_password
Definition: cli.h:545
void SetPrompt(const PString &prompt)
Set prompt used for command line interpreter.
Definition: cli.h:393
void SetHelpCommand(const PCaselessString &helpCommand)
Set command to be used to display help.
Definition: cli.h:453
PString m_commandErrorPrefix
Definition: cli.h:553
void SetExitCommand(const PCaselessString &exitCommand)
Set command to be used to exit session.
Definition: cli.h:443
virtual PTCPSocket * CreateSocket()
PString m_command
Definition: cli.h:216
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
Command Line Interpreter class.
Definition: cli.h:56
const PString & GetPasswordPrompt() const
Get prompt used for password (if enabled).
Definition: cli.h:408
virtual Context * StartForeground()
Initialise a foreground context and return it.
virtual void OnCompletedLine()
Call back for a command line was completed and ENTER pressed.
virtual void RemoveContext(Context *context)
Remove the command line interpreter context.
WORD GetPort() const
Get the port the TCP socket channel object instance is using.
void SetRequireEcho(bool requireEcho)
Set flag for echo is required for entered characters.
Definition: cli.h:373
bool Listen(WORD port=0)
Start listening socket.
virtual bool OnLogIn(const PString &username, const PString &password)
Received a login name/pasword to be verified.
PCLI & GetCLI() const
Get the CLI.
Definition: cli.h:156