Esempio n. 1
0
        /// <summary>
        /// Shake console app main entry point.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        private static void Main(string[] args)
        {
            SetupCastle();
            return;

            // log console output
            var logger = new TextWriterLogger(Console.Out);
            Console.SetOut(logger);

            // parse command line args
            Arguments = new ShakeArgs(args);

            Console.Title = ReflectionHelper.AssemblyTitle;
            Console.WriteLine("{0} v{1}", ReflectionHelper.AssemblyTitle, ReflectionHelper.ShortAssemblyVersion);
            Console.WriteLine("Copyright (c) 2010 Kalman Speier");
            Console.WriteLine("http://shake.codeplex.com\n");

            if (Arguments.ShowHelp)
            {
                WriteOutUsage();
                return;
            }

            if (File.Exists(Arguments.ShakeFilePath))
            {
                var stopWatch = Stopwatch.StartNew();
                try
                {
                    // start shake
                    Run(Arguments);
                }
                catch (Exception ex)
                {
                    Environment.ExitCode = ShakeErrors.Exception;

                    if (!string.IsNullOrEmpty(ex.Message))
                        Console.WriteLine(ex.Message);
                }
                finally
                {
                    stopWatch.Stop();
                    var elapsed = stopWatch.Elapsed;

                    Console.WriteLine("\nFinished.\n");
                    Console.WriteLine("Total time: {0}.{1} seconds.",
                        elapsed.Seconds, elapsed.Milliseconds / 100);

                    if (Arguments.WriteLog)
                        logger.SaveToFile(Arguments.LogFilePath);
                }
            }
            else
            {
                Environment.ExitCode = ShakeErrors.ShakefileNotFound;

                Console.WriteLine("Shakefile not found.\n{0}\n", Arguments.ShakeFilePath);
                WriteOutUsage();
            }

            if (Debugger.IsAttached)
                Console.ReadKey();
        }
Esempio n. 2
0
        /// <summary>
        /// Evaluate a shakefile.
        /// </summary>
        /// <param name="args">Shake arguments.</param>
        internal static void EvaluateShakeFile(ShakeArgs args)
        {
            var file = EvaluateFile(args.ShakeFilePath);

            var classMatch = RegexHelper.FormatMatch(file, "class (?<Name>{0})", args.ShakeClassName);
            if (classMatch.Success)
            {
                var className = classMatch.Groups["Name"].Value;
                var classVar = className.ToLower();

                EvaluateStatement("var {0} = new {1}();", classVar, className);

                foreach (var targetName in args.Targets)
                {
                    var targetMatch = RegexHelper.FormatMatch(file, @"public void {0}\(\)", targetName);

                    if (targetMatch.Success)
                        EvaluateTarget(classVar, targetName);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Init shake runner and evaluate shakefile.
        /// </summary>
        /// <param name="arguments">Shake arguments.</param>
        private static void Run(ShakeArgs arguments)
        {
            // Init shake runner
            ShakeRunner.Init(ReflectionHelper.ExecutingAssembly, "Shake.Services", "Shake.Tasks");

            // Evaluate shake API
            ShakeRunner.EvalApiClass("shake",
                new ApiClassWrapper(typeof(CommandLineService), true),
                new ApiClassWrapper(typeof(ProjectService), false));

            ShakeRunner.OnEvaluateTarget += (e) => Console.WriteLine("Target: {0}\n", e.TargetName);

            // Evaluate shakefile
            ShakeRunner.EvaluateShakeFile(arguments);
        }