You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Iuga Alexandru edited this page Aug 31, 2018
·
5 revisions
Description
Displays a prompter and reads a command from the user.
Useful when writing a stateful CLI application in which the user can write commands to the console.
Features
Customizable prompter text
Customizable prompter glyph
Read commands repeatedly - Reads commands in a loop until the RequireStop method is called.
Read one command - Read a single command, parses and returns it.
Example
Read repeatedly
Note: For a complete example please see the demo project.
privatestaticvoidRunDemo(){Prompterprompter=newPrompter();prompter.NewCommand+=HandleNewCommand;prompter.Display();}privatestaticvoidHandleNewCommand(objectsender,NewCommandEventArgse){try{CliCommandcommand=e.Command;// Do something based on the command.}catch(Exceptionex){CustomConsole.WriteError(ex);}}