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

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

            CurrentState.Log.LogLevel = args.Verbose ? Api.LogLevel.Detail : Api.LogLevel.Info;

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

            using (var l = new FolderLock(args.Directory))
            {
                using (var server = new HttpServer(args.Directory, 8081, CurrentState.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);
        }
Пример #2
0
        public override bool Execute(string[] arguments)
        {
            BookGenArgumentBase args = new BookGenArgumentBase();

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

            CurrentState.Gui             = true;
            CurrentState.GeneratorRunner = Program.CreateRunner(args.Verbose, args.Directory);

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

            using (var l = new FolderLock(args.Directory))
            {
                System.IO.Stream?Ui = typeof(GuiModule).Assembly.GetManifestResourceStream("BookGen.ConsoleUi.MainView.xml");
                var vm = new MainViewModel(CurrentState.GeneratorRunner);

                if (Ui != null)
                {
                    uiRunner.Run(Ui, vm);
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
        public override bool Execute(string[] arguments)
        {
            var parameters = new AssemblyDocumentParameters();

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

            FolderLock.ExitIfFolderIsLocked(parameters.OutputDirectory.ToString(), CurrentState.Log);

            using (var l = new FolderLock(parameters.OutputDirectory.ToString()))
            {
                XmlDocMarkdownGenerator.Generate(parameters.AssemblyPath.ToString(),
                                                 parameters.OutputDirectory.ToString(),
                                                 new XmlDocMarkdownSettings
                {
                    IsQuiet         = true,
                    ShouldClean     = true,
                    VisibilityLevel = XmlDocVisibilityLevel.Protected,
                    SkipUnbrowsable = true,
                });
            }

            return(true);
        }
Пример #4
0
        /// <summary>
        /// Initialize the controller.
        /// </summary>
        /// <param name="firstRun">Whether it is the first time that CmisSync is being run.</param>
        public virtual void Initialize(Boolean firstRun)
        {
            this.firstRun = firstRun;

            // Create the CmisSync folder and add it to the bookmarks
            bool syncFolderCreated = CreateCmisSyncFolder();

            if (syncFolderCreated)
            {
                //Dont add bookmark for Oris4
                AddToBookmarks();
            }

            if (firstRun)
            {
                ConfigManager.CurrentConfig.Notifications = true;
            }

            folderLock = new FolderLock(FoldersPath);

            autoUpdater = new Sparkle("http://update.oris4.com/versioninfo.xml")
            {
                //ShowDiagnosticWindow = true,
                //EnableSystemProfiling = true,
                //SystemProfileUrl = new Uri("http://update.oris4.com/profile.html"),
            };

            autoUpdater.StartLoop(true, true);
        }
Пример #5
0
        public override bool Execute(string[] arguments)
        {
            BookGenArgumentBase args = new BookGenArgumentBase();

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

            CurrentState.Log.LogLevel = args.Verbose ? Api.LogLevel.Detail : Api.LogLevel.Info;

            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);
        }
Пример #6
0
        public override bool Execute(string[] arguments)
        {
            ChaptersParameters args = new ChaptersParameters();

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

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

            using (var l = new FolderLock(args.WorkDir))
            {
                var loader = new ProjectLoader(CurrentState.Log, args.WorkDir);

                if (!loader.TryLoadAndValidateConfig(out Config? configuration) ||
                    configuration == null)
                {
                    return(false);
                }

                switch (args.Action)
                {
                case ChaptersAction.GenSummary:
                    return(ChapterProcessingUtils.GenerateSummaryFile(args.WorkDir, configuration, CurrentState.Log));

                case ChaptersAction.Scan:
                    ChapterProcessingUtils.ScanMarkdownFiles(args.WorkDir, configuration, CurrentState.Log);
                    break;
                }
            }

            return(true);
        }
Пример #7
0
        public override bool Execute(string[] arguments)
        {
            BookGenArgumentBase args = new BookGenArgumentBase();

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

            CurrentState.Gui             = true;
            CurrentState.GeneratorRunner = Program.CreateRunner(args.Verbose, args.Directory);

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

            using (var l = new FolderLock(args.Directory))
            {
                if (uiRunner != null)
                {
                    uiRunner.OnNavigaton += UiRunner_OnNavigaton;
                    var(view, model)      = UiRunner_OnNavigaton(MainView);
                    uiRunner.Run(view, model);
                    return(true);
                }
            }
            return(false);
        }
Пример #8
0
        public override bool Execute(string[] arguments)
        {
            var args = new StatParameters();

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

            var stat = new StatisticsData();

            if (!string.IsNullOrEmpty(args.Input))
            {
                if (TryComputeStat(args.Input, ref stat))
                {
                    stat.Pages = (double)stat.Chars / StatisticsData.CharsPerA4Page;
                    CurrentState.Log.PrintLine(stat);
                    return(true);
                }
                return(false);
            }
            else
            {
                FolderLock.ExitIfFolderIsLocked(args.Directory, CurrentState.Log);

                using (var l = new FolderLock(args.Directory))
                {
                    ProjectLoader loader = new ProjectLoader(CurrentState.Log, args.Directory);
                    bool          result = loader.TryLoadProjectAndExecuteOperation((config, toc) =>
                    {
                        var settings = loader.CreateRuntimeSettings(config, toc, new BuildConfig());

                        foreach (var link in settings.TocContents.Files)
                        {
                            if (!TryComputeStat(link, ref stat))
                            {
                                return(false);
                            }
                        }
                        return(true);
                    });

                    if (result)
                    {
                        stat.Pages = (double)stat.Chars / StatisticsData.CharsPerA4Page;
                        CurrentState.Log.PrintLine(stat);
                    }

                    return(result);
                }
            }
        }
Пример #9
0
        public override bool Execute(string[] arguments)
        {
            BuildParameters args = new BuildParameters();

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

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

            using (var l = new FolderLock(args.Directory))
            {
                CurrentState.GeneratorRunner        = Program.CreateRunner(args.Verbose, args.Directory);
                CurrentState.GeneratorRunner.NoWait = args.NoWaitForExit;

                switch (args.Action)
                {
                case BuildAction.BuildWeb:
                    CurrentState.GeneratorRunner.InitializeAndExecute(x => x.DoBuild());
                    break;

                case BuildAction.Clean:
                    CurrentState.GeneratorRunner.InitializeAndExecute(x => x.DoClean());
                    break;

                case BuildAction.Test:
                    CurrentState.GeneratorRunner.InitializeAndExecute(x => x.DoTest());
                    break;

                case BuildAction.BuildPrint:
                    CurrentState.GeneratorRunner.InitializeAndExecute(x => x.DoPrint());
                    break;

                case BuildAction.BuildWordpress:
                    CurrentState.GeneratorRunner.InitializeAndExecute(x => x.DoWordpress());
                    break;

                case BuildAction.BuildEpub:
                    CurrentState.GeneratorRunner.InitializeAndExecute(x => x.DoEpub());
                    break;

                case BuildAction.ValidateConfig:
                    CurrentState.GeneratorRunner.Initialize();
                    break;
                }
            }

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

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

            CurrentState.Log.LogLevel = args.Verbose ? Api.LogLevel.Detail : Api.LogLevel.Info;

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

            using (var l = new FolderLock(args.Directory))
            {
                ProjectLoader loader = new ProjectLoader(CurrentState.Log, args.Directory);

                loader.TryLoadProjectAndExecuteOperation((config, toc) =>
                {
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();

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

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

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

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

                    return(true);
                });
            }

            return(false);
        }
Пример #11
0
        /// <summary>
        /// Initialize the controller.
        /// </summary>
        /// <param name="firstRun">Whether it is the first time that CmisSync is being run.</param>
        public virtual void Initialize(Boolean firstRun)
        {
            this.firstRun = firstRun;

            // Create the CmisSync folder and add it to the bookmarks
            bool syncFolderCreated = CreateCmisSyncFolder();

            if (syncFolderCreated)
            {
                AddToBookmarks();
            }

            if (firstRun)
            {
                ConfigManager.CurrentConfig.Notifications = true;
            }

            folderLock = new FolderLock(FoldersPath);
        }
Пример #12
0
        public override bool Execute(string[] arguments)
        {
            var parameters = new AssemblyDocumentParameters();

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

            FolderLock.ExitIfFolderIsLocked(parameters.OutputDirectory.ToString(), CurrentState.Log);

            using (var l = new FolderLock(parameters.OutputDirectory.ToString()))
            {
                var documenter = new AssemblyDocumenter.AssemblyDocumenter(CurrentState.Log);

                documenter.Document(parameters.AssemblyPath, parameters.XmlPath, parameters.OutputDirectory);
            }

            return(true);
        }