示例#1
0
        public override bool Execute(string[] arguments)
        {
            ChaptersParameters args = new ChaptersParameters();

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

            var log = new ConsoleLog(LogLevel.Info);

            var loader = new ProjectLoader(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, log));

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

            return(true);
        }
示例#2
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);
        }