Example #1
0
        public void Run(string[] args, MethodInfo getTargetsMethod)
        {
            TargetsPath = new Uri(getTargetsMethod.Module.Assembly.CodeBase).LocalPath;

            var parameters = new CommandLineParameters();

            try {
                IDictionary<string, ITask> targets = GetTargetsFromAssembly(getTargetsMethod, parameters);

                ParsedCommandLineParameters parsedParameters = ParseCommandLineArguments(args);

                string[] buildArguments = parsedParameters.RemainingArguments;

                CommandAndTargets commandAndTargets = CommandAndTargetParser.ParseCommandAndTargetNames(buildArguments, targets);

                if (commandAndTargets.Targets.Count() >= 1) {
                    var bounce = new Bounce();

                    InterpretParameters(parameters, parsedParameters, bounce);

                    try
                    {
                        EnsureAllRequiredParametersAreSet(parameters, commandAndTargets.Targets);

                        BuildTargets(bounce, commandAndTargets);
                    }
                    catch (BounceException ce)
                    {
                        ce.Explain(bounce.LogOptions.StdErr);
                        Environment.Exit(1);
                    }
                }
                else
                {
                    System.Console.WriteLine("usage: bounce build|clean target-name");
                    PrintAvailableTargets(targets);
                    Environment.Exit(1);
                }
            } catch (BounceException ce) {
                ce.Explain(System.Console.Error);
                Environment.Exit(1);
            }
        }
Example #2
0
        public int Run(string bounceDirectory, string [] rawArguments)
        {
            try {
                Directory.SetCurrentDirectory(Path.GetDirectoryName(bounceDirectory));
                var arguments = ParsedArguments(rawArguments);

                Bounce.SetUp(arguments);

                var dependencyResolver = new AttributedDependencyResolvers();
                var tasks = Tasks(bounceDirectory, dependencyResolver);

                if (rawArguments.Length > 0)
                {
                    RunTask(TaskName(rawArguments), arguments, tasks);
                }
                else
                {
                    UsageHelp.WriteUsage(Console.Out, tasks);
                }
                return(0);
            } catch (BounceException e) {
                e.Explain(Console.Error);
                return(1);
            } catch (ReflectionTypeLoadException e) {
                foreach (var loaderException in e.LoaderExceptions)
                {
                    Console.Error.WriteLine(loaderException);
                }
                return(1);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
                return(1);
            }
        }
Example #3
0
        private void InterpretParameters(ICommandLineParameters parameters, ParsedCommandLineParameters parsedParameters, Bounce bounce)
        {
            parsedParameters.IfParameterDo("loglevel", loglevel => bounce.LogOptions.LogLevel = ParseLogLevel(loglevel));
            parsedParameters.IfParameterDo("command-output", commandOutput => bounce.LogOptions.CommandOutput = commandOutput.ToLower() == "true");
            parsedParameters.IfParameterDo("logformat", logformat => bounce.LogFactory = GetLogFactoryByName(logformat));

            parameters.ParseCommandLineArguments(parsedParameters.Parameters);
        }
Example #4
0
 private void InterpretParameters(ICommandLineParameters parameters, ParsedCommandLineParameters parsedParameters, Bounce bounce)
 {
     LogOptionCommandLineTranslator.ParseCommandLine(parsedParameters, bounce);
     bounce.ParametersGiven = parameters.ParseCommandLineArguments(parsedParameters.Parameters);
 }
Example #5
0
 private void BuildTargets(Bounce bounce, CommandAndTargets commandAndTargets)
 {
     TargetsBuilder.BuildTargets(bounce, commandAndTargets.Targets, commandAndTargets.Command);
     bounce.CleanAfterBuild(commandAndTargets.Command);
 }
Example #6
0
 private void BuildTargets(Bounce bounce, CommandAndTargets commandAndTargets)
 {
     foreach(var target in commandAndTargets.Targets) {
         BuildTarget(bounce, target, commandAndTargets.Command);
     }
     bounce.CleanAfterBuild(commandAndTargets.Command);
 }
Example #7
0
 private void BuildTarget(Bounce bounce, Target target, IBounceCommand command)
 {
     using (ITaskScope targetScope = bounce.TaskScope(target.Task, command, target.Name)) {
         bounce.Invoke(command, target.Task);
         targetScope.TaskSucceeded();
     }
 }