Inheritance: PowerArgs.ArgHook, ICommandLineArgumentsDefinitionMetadata
コード例 #1
0
        internal static T DriveREPL <T>(TabCompletion t, Func <string[], T> eval, string[] args) where T : class
        {
            T ret = null;

            bool first = true;

            do
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    args = string.IsNullOrWhiteSpace(t.Indicator) ? new string[0] : new string[] { t.Indicator };
                }

                try
                {
                    ret = eval(args);
                }
                catch (REPLExitException)
                {
                    return(ret);
                }
                catch (REPLContinueException)
                {
                }
            }while (t != null && t.REPL);

            return(ret);
        }
コード例 #2
0
ファイル: REPL.cs プロジェクト: mobiletta/PowerArgs
        internal static T DriveREPL <T>(TabCompletion t, Func <string[], T> eval, string[] args, Func <T> defaultEval) where T : class
        {
            T ret = null;

            bool first = true;

            do
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    args = string.IsNullOrWhiteSpace(t.Indicator) ? new string[0] : new string[] { t.Indicator };
                }

                try
                {
                    ret = eval(args);
                }
                catch (REPLExitException)
                {
                    return(ret ?? defaultEval());
                }
                catch (REPLContinueException)
                {
                    if (ConsoleProvider.Current.CursorLeft > 0)
                    {
                        ConsoleProvider.Current.WriteLine();
                    }
                }
            }while (t != null && t.REPL);

            return(ret);
        }