PowerArgs.Cli.CliHelper.PromptForLine C# (CSharp) Method

PromptForLine() public method

Prompts the user for a line of input with the given message
public PromptForLine ( string message ) : string
message string the prompt message
return string
        public string PromptForLine(string message)
        {
            if(message.EndsWith(": ") == false)
            {
                message += ": ";
            }
            ConsoleString.Write(message, ConsoleColor.Yellow);
            var input = Reader.ReadLine().ToString();
            return input;
        }

Usage Example

        /// <summary>
        /// Prompts the user to enter a value for the given property in the case that the option was specified with no value
        /// </summary>
        /// <param name="context">the parser context</param>
        public override void BeforePopulateProperty(ArgHook.HookContext context)
        {
            if (context.ArgumentValue == string.Empty)
            {
                var cli = new CliHelper();

                ITabCompletionHandler tabHandler;
                IHighlighterConfigurator highlighterConfigurator;

                if (TabCompletionHandlerType.TryCreate<ITabCompletionHandler>(out tabHandler))
                {
                    cli.Reader.TabHandler.TabCompletionHandlers.Add(tabHandler);
                }

                if (HighlighterConfiguratorType.TryCreate<IHighlighterConfigurator>(out highlighterConfigurator))
                {
                    cli.Reader.Highlighter = new SimpleSyntaxHighlighter();
                    highlighterConfigurator.Configure(cli.Reader.Highlighter);
                }

                context.ArgumentValue = cli.PromptForLine("Enter value for " + context.CurrentArgument.DefaultAlias);
            }
        }
All Usage Examples Of PowerArgs.Cli.CliHelper::PromptForLine