コード例 #1
0
        public override bool Execute(string[] arguments)
        {
            BookGenArgumentBase args = new BookGenArgumentBase();

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

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

            CurrentState.Log.LogLevel = logLevel;

            FolderLock.ExitIfFolderIsLocked(args.Directory, CurrentState.Log);

            using (var l = new FolderLock(args.Directory))
            {
                System.IO.Stream?Ui = typeof(GuiModule).Assembly.GetManifestResourceStream("BookGen.ConsoleUi.InitializeView.xml");
                var vm = new InitializeViewModel(CurrentState.Log, new FsPath(args.Directory));

                if (Ui != null)
                {
                    uiRunner.Run(Ui, vm);
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
ファイル: PagegenModule.cs プロジェクト: shuizhugeju/BookGen
        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);
        }
コード例 #3
0
        public override bool Execute(string[] arguments)
        {
            BookGenArgumentBase args = new BookGenArgumentBase();

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

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

            var log = new ConsoleLog(logLevel);

            System.IO.Stream?Ui = typeof(GuiModule).Assembly.GetManifestResourceStream("BookGen.ConsoleUi.InitializeView.xml");
            var vm = new InitializeViewModel(log, new FsPath(args.Directory));

            if (Ui != null)
            {
                uiRunner.Run(Ui, vm);
                return(true);
            }
            return(false);
        }
コード例 #4
0
ファイル: ServeModule.cs プロジェクト: shuizhugeju/BookGen
        public override bool Execute(string[] arguments)
        {
            BookGenArgumentBase args = new BookGenArgumentBase();

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

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

            var log = new ConsoleLog(logLevel);

            using (var server = new HttpServer(args.Directory, 8081, log))
            {
                Console.WriteLine("Serving: {0}", args.Directory);
                Console.WriteLine("Server running on http://localhost:8081");
                Console.WriteLine("Press a key to exit...");
                Console.ReadLine();
            }


            return(true);
        }