Example #1
0
        private static async Task <int> SpellcheckAsync(SpellcheckCommandLineOptions options)
        {
            if (!TryParseOptionValueAsEnumFlags(
                    options.Scope,
                    OptionNames.Scope,
                    out SpellingScopeFilter scopeFilter,
                    SpellingScopeFilter.Comment | SpellingScopeFilter.Region | SpellingScopeFilter.Symbol))
            {
                return(ExitCodes.Error);
            }

            if (!TryParseOptionValueAsEnumFlags(options.IgnoredScope, OptionNames.IgnoredScope, out SpellingScopeFilter ignoredScopeFilter, SpellingScopeFilter.None))
            {
                return(ExitCodes.Error);
            }

            scopeFilter &= ~ignoredScopeFilter;

            if (!TryParseOptionValueAsEnum(options.Visibility, OptionNames.Visibility, out Visibility visibility))
            {
                return(ExitCodes.Error);
            }

            if (!options.TryGetProjectFilter(out ProjectFilter projectFilter))
            {
                return(ExitCodes.Error);
            }

            if (!ParseHelpers.TryEnsureFullPath(options.Words, out ImmutableArray <string> wordListPaths))
            {
                return(ExitCodes.Error);
            }

            if (!TryParsePaths(options.Paths, out ImmutableArray <string> paths))
            {
                return(ExitCodes.Error);
            }

            WordListLoaderResult loaderResult = WordListLoader.Load(
                wordListPaths,
                options.MinWordLength,
                options.MaxWordLength,
                (options.CaseSensitive) ? WordListLoadOptions.None : WordListLoadOptions.IgnoreCase);

            var data = new SpellingData(loaderResult.List, loaderResult.CaseSensitiveList, loaderResult.FixList);

            var command = new SpellcheckCommand(options, projectFilter, data, visibility, scopeFilter);

            CommandStatus status = await command.ExecuteAsync(paths, options.MSBuildPath, options.Properties);

            return(GetExitCode(status));
        }
Example #2
0
 public SpellcheckCommand(
     SpellcheckCommandLineOptions options,
     in ProjectFilter projectFilter,