Пример #1
0
        public override bool Execute(string[] arguments)
        {
            PageGenParameters args = new PageGenParameters();

            if (!ArgumentParser.ParseArguments(arguments, args))
            {
                return(false);
            }

            Api.LogLevel logLevel = args.Verbose ? Api.LogLevel.Detail : Api.LogLevel.Info;

            ILog log = new ConsoleLog(logLevel);

            ProjectLoader loader = new ProjectLoader(log, args.Directory);

            if (loader.TryLoadAndValidateConfig(out var config) &&
                loader.TryLoadAndValidateToc(config, out var toc) &&
                config != null &&
                toc != null)
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                var settings = loader.CreateRuntimeSettings(config, toc, new BuildConfig());

                switch (args.PageType)
                {
                case PageType.ExternalLinks:
                    RunGetLinks(settings, log);
                    break;

                case PageType.Chaptersummary:
                    RunChapterSummary(settings, log);
                    break;
                }

                stopwatch.Stop();
                log.Info("Total runtime: {0}ms", stopwatch.ElapsedMilliseconds);

                return(true);
            }

            return(false);
        }