add --exclude cli option

This excludes given files or directory from linting
This commit is contained in:
Axel Ricard 2023-10-05 16:45:34 +02:00 committed by Jan Jurzitza
parent 87f85c7db7
commit 3bf3f25f9a
1 changed files with 21 additions and 2 deletions

View File

@ -72,6 +72,7 @@ else
string symbolName; string symbolName;
string configLocation; string configLocation;
string[] importPaths; string[] importPaths;
string[] excludePaths;
bool printVersion; bool printVersion;
bool explore; bool explore;
bool verbose; bool verbose;
@ -108,6 +109,7 @@ else
"resolveMessage", &resolveMessage, "resolveMessage", &resolveMessage,
"applySingle", &applySingleFixes, "applySingle", &applySingleFixes,
"I", &importPaths, "I", &importPaths,
"exclude", &excludePaths,
"version", &printVersion, "version", &printVersion,
"muffinButton", &muffin, "muffinButton", &muffin,
"explore", &explore, "explore", &explore,
@ -197,6 +199,21 @@ else
} }
} }
if (excludePaths.length)
{
args = expandArgs(args);
string[] newArgs = [args[0]];
foreach(arg; args[1 .. $])
{
if(!excludePaths.map!(p => arg.isSubpathOf(p))
.fold!((a, b) => a || b))
newArgs ~= arg;
}
args = newArgs;
}
if (!errorFormat.length) if (!errorFormat.length)
errorFormat = defaultErrorFormat; errorFormat = defaultErrorFormat;
else if (auto errorFormatSuppl = errorFormat in errorFormatMap) else if (auto errorFormatSuppl = errorFormat in errorFormatMap)
@ -208,8 +225,7 @@ else
.replace("\\n", "\n") .replace("\\n", "\n")
.replace("\\t", "\t"); .replace("\\t", "\t");
const(string[]) absImportPaths = importPaths.map!(a => a.absolutePath() const(string[]) absImportPaths = importPaths.map!absoluteNormalizedPath.array;
.buildNormalizedPath()).array();
ModuleCache moduleCache; ModuleCache moduleCache;
@ -450,6 +466,9 @@ Options:
modules. This option can be passed multiple times to specify multiple modules. This option can be passed multiple times to specify multiple
directories. directories.
--exclude <file | directory>..., <file | directory>
Specify files or directories that will be ignored by D-Scanner.
--syntaxCheck <file>, -s <file> --syntaxCheck <file>, -s <file>
Lexes and parses sourceFile, printing the line and column number of Lexes and parses sourceFile, printing the line and column number of
any syntax errors to stdout. One error or warning is printed per line, any syntax errors to stdout. One error or warning is printed per line,