public void Execute(NewCommandInput input, TemplatePlan plan, Action <TemplatePlanContext> continuation)
        {
            var context = new TemplatePlanContext
            {
                Input   = input,
                TempDir = createTempDir()
            };

            _fileSystem.CreateDirectory(context.TempDir);

            var targetPath = input.ProjectName;

            if (input.OutputFlag.IsNotEmpty())
            {
                targetPath = input.OutputFlag;
            }
            else if (input.SolutionFlag.IsNotEmpty())
            {
                targetPath = _fileSystem.GetDirectory(input.SolutionFlag);
            }

            context.TargetPath = Path.Combine(Environment.CurrentDirectory, targetPath);

            plan.Preview(context);

            try
            {
                plan
                .Steps
                .Each(step => step.Execute(context));
            }
            catch (Exception exc)
            {
                context.RegisterError(exc.Message);
                context.RegisterError(exc.StackTrace);
            }

            continuation(context);
            _fileSystem.DeleteDirectory(context.TempDir);
        }
Example #2
0
        public void Execute(NewCommandInput input, TemplatePlan plan, Action<TemplatePlanContext> continuation)
        {
            var context = new TemplatePlanContext
                              {
                                  Input = input,
                                  TempDir = createTempDir()
                              };

            _fileSystem.CreateDirectory(context.TempDir);

            var targetPath = input.ProjectName;
            if(input.OutputFlag.IsNotEmpty())
            {
                targetPath = input.OutputFlag;
            }
            else if(input.SolutionFlag.IsNotEmpty())
            {
                targetPath = _fileSystem.GetDirectory(input.SolutionFlag);
            }

            context.TargetPath = Path.Combine(Environment.CurrentDirectory, targetPath);

            plan.Preview(context);

            try
            {
                plan
                    .Steps
                    .Each(step => step.Execute(context));
            }
            catch (Exception exc)
            {
                context.RegisterError(exc.Message);
                context.RegisterError(exc.StackTrace);
            }

            continuation(context);
            _fileSystem.DeleteDirectory(context.TempDir);
        }
Example #3
0
 public void before_each()
 {
     _plan = new TemplatePlan();
 }