PowerArgs.PromptIfEmpty.BeforePopulateProperty C# (CSharp) Method

BeforePopulateProperty() public method

Prompts the user to enter a value for the given property in the case that the option was specified with no value
public BeforePopulateProperty ( PowerArgs.ArgHook context ) : void
context PowerArgs.ArgHook the parser context
return void
        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);
            }
        }