/// <summary>
 /// Creates a new stage given a set of command line arguments
 /// </summary>
 /// <param name="args"></param>
 public PipelineStage(string[] args)
 {
     _cmdLineArgs = new List <string>(args);
     CommandLineDefinitionFactory = new ArgumentScaffoldTypeCommandLineDefinitionFactory();
 }
        internal PipelineStage CreateNextStage(ArgHook.HookContext context, string[] commandLine, ICommandLineArgumentsDefinitionFactory factory)
        {
            PipelineStage next;
            CommandLineAction inProcAction;

            if (Stages.Count == 0)
            {
                next = new RootPipelineStage(commandLine);
            }
            else if (commandLine[0].StartsWith(ArgPipeline.PipelineStageActionIndicator) && ArgPipelineActionStage.TryCreateActionStage(commandLine, out next))
            {
                // do nothing, next is populated
            }
            else if (TryParseStageAction(context.Definition, commandLine[0], out inProcAction))
            {
                next = new InProcessPipelineStage(context.Definition, commandLine);
            }
            else if (ExternalPipelineProvider.TryLoadOutputStage(commandLine, out next) == false)
            {
                throw new UnexpectedArgException("The pipeline action '"+string.Join(" ", commandLine)+"' is not valid.  If you want to support piping between processes, learn how to here (TODO URL)");
            }

            next.CommandLineDefinitionFactory = factory;

            this.AddStage(next);
            return next;
        }
        internal PipelineStage CreateNextStage(ArgHook.HookContext context, string[] commandLine, ICommandLineArgumentsDefinitionFactory factory)
        {
            PipelineStage     next;
            CommandLineAction inProcAction;

            if (Stages.Count == 0)
            {
                next = new RootPipelineStage(commandLine);
            }
            else if (commandLine[0].StartsWith(ArgPipeline.PipelineStageActionIndicator) && ArgPipelineActionStage.TryCreateActionStage(commandLine, out next))
            {
                // do nothing, next is populated
            }
            else if (TryParseStageAction(context.Definition, commandLine[0], out inProcAction))
            {
                next = new InProcessPipelineStage(context.Definition, commandLine);
            }
            else if (ExternalPipelineProvider.TryLoadOutputStage(commandLine, out next) == false)
            {
                throw new UnexpectedArgException("The pipeline action '" + string.Join(" ", commandLine) + "' is not valid.  If you want to support piping between processes, learn how to here (TODO URL)");
            }

            next.CommandLineDefinitionFactory = factory;

            this.AddStage(next);
            return(next);
        }