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 660 WORD
GetPort()
const {
return m_listenSocket.GetPort(); }
665 bool HandleSingleThreadForAll();
666 bool HandleIncoming();
690 const char * prompt = NULL,
691 bool singleThreadForAll =
false 700 #endif // PTLIB_CLI_H PTCPSocket m_listenSocket
Definition: cli.h:671
const PCaselessString & GetExitCommand() const
Get command to be used to exit session.
Definition: cli.h:438
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
PCLI & GetCLI() const
Get the CLI.
Definition: cli.h:156
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.
const PString & GetPrompt() const
Get prompt used for command line interpreter.
Definition: cli.h:388
PMutex m_contextMutex
Definition: cli.h:566
Context & GetContext() const
Get the CLI context supplying the command line arguments.
Definition: cli.h:211
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>
const PString & GetUsernamePrompt() const
Get prompt used for login (if enabled).
Definition: cli.h:398
PCaselessString m_historyCommand
Definition: cli.h:550
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.
virtual Context * AddContext(Context *context=NULL)
Add a command line interpreter context to the system.
const PString & GetHelpOnHelp() const
Get help on help.
Definition: cli.h:459
virtual bool WritePrompt()
Write prompt (depending on state) to channel.
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
bool GetRequireEcho() const
Get flag for echo is required for entered characters.
Definition: cli.h:368
virtual void OnReceivedLine(Arguments &line)
Received a completed command line.
Context(PCLI &cli)
Construct new command line interpreter context.
PString m_username
Definition: cli.h:544
void SetCommandErrorPrefix(const PString &commandErrorPrefix)
Set error prefix for if Arguments::WriteError() called.
Definition: cli.h:515
PNotifier m_notifier
Definition: cli.h:557
PChannel * readChannel
Channel for read operations.
Definition: indchan.h:301
const PString & GetUnknownCommandError() const
Get error message for if unknown command is entered.
Definition: cli.h:520
bool Start()
Start a command line interpreter thread.
virtual ~Context()
Destroy command line interpreter context.
CommandMap_t m_commands
Definition: cli.h:562
const PString & GetCommandErrorPrefix() const
Get error prefix for if Arguments::WriteError() called.
Definition: cli.h:510
BOOL PBoolean
Definition: object.h:102
WORD GetPort() const
Get the port we are listing on.
Definition: cli.h:660
bool m_requireEcho
Definition: cli.h:539
PChannel * writeChannel
Channel for write operations.
Definition: indchan.h:307
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 m_singleThreadForAll
Definition: cli.h:669
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.
const PString & GetPassword() const
Get password for log in validation.
Definition: cli.h:428
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
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
PString m_unknownCommandError
Definition: cli.h:554
Command Line Interpreter over standard input/output.
Definition: cli.h:572
virtual bool ProcessInput(int ch)
Process a character read from the channel.
const PString & GetNoHistoryError() const
Get error message for if there is no history.
Definition: cli.h:490
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
PString m_usage
Definition: cli.h:559
void SetPassword(const PString &password)
Set password for log in validation.
Definition: cli.h:433
A socket that uses the TCP transport on the Internet Protocol.
Definition: tcpsock.h:44
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
const PString & GetEditCharacters() const
Get characters used for editing (backspace/delete) command lines.
Definition: cli.h:378
enum PCLI::Context::State m_state
PCaselessString m_repeatCommand
Definition: cli.h:549
const PString & GetNewLine() const
Get new line string output at the end of every line.
Definition: cli.h:358
PString m_help
Definition: cli.h:558
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
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
bool IsProcessingCommand() const
Indicate is currently processing a command.
Definition: cli.h:160
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.
ContextList_t m_contextList
Definition: cli.h:565
void Stop()
Stop command line interpreter context.
virtual Context * CreateContext()
Create a new context.
const PString & GetPasswordPrompt() const
Get prompt used for password (if enabled).
Definition: cli.h:408
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
const PString & GetCommandUsagePrefix() const
Get usage prefix for if Arguments::WriteUsage() called.
Definition: cli.h:500
virtual void OnStart()
Call back frunction for when context is started.
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
const PCaselessString & GetHelpCommand() const
Get command to be used to display help.
Definition: cli.h:448
void SetExitCommand(const PCaselessString &exitCommand)
Set command to be used to exit session.
Definition: cli.h:443
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
virtual Context * StartForeground()
Initialise a foreground context and return it.
virtual void OnCompletedLine()
Call back for a command line was completed and ENTER pressed.
void Broadcast(const PString &message) const
Set a string to all command line interpreter contexts.
const PCaselessString & GetRepeatCommand() const
Get the command to be used to repeat the last executed command.
Definition: cli.h:470
virtual void RemoveContext(Context *context)
Remove the command line interpreter context.
const PCaselessString & GetHistoryCommand() const
Get command that will list/execute command history.
Definition: cli.h:480
const PString & GetUsername() const
Get username for log in validation.
Definition: cli.h:418
void SetRequireEcho(bool requireEcho)
Set flag for echo is required for entered characters.
Definition: cli.h:373
virtual bool OnLogIn(const PString &username, const PString &password)
Received a login name/pasword to be verified.