Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Jump.Location/GetJumpStatusCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class GetJumpStatusCommand : PSCmdlet
[AllowEmptyString]
public string Scan { get; set; }

[Parameter(HelpMessage = "Exclude directories and all subdirectories from scan.")]
[AllowEmptyCollection]
public string[] Exclude { get; set; }

protected override void ProcessRecord()
{

Expand Down Expand Up @@ -101,7 +105,7 @@ private void DoScan()
private IEnumerable<string> GetChildFoldersRec(string path)
{
yield return path;
foreach (string dir in Directory.GetDirectories(path))
foreach (string dir in Directory.GetDirectories(path).Where(ScanIncludesDirectory))
{
foreach (string childDir in GetChildFoldersRec(dir))
{
Expand All @@ -110,6 +114,16 @@ private IEnumerable<string> GetChildFoldersRec(string path)
}
}

private bool ScanIncludesDirectory(string path)
{
if (null == Exclude || Exclude.Length == 0)
{
return true;
}

return !Exclude.Contains(new DirectoryInfo(path).Name, StringComparer.OrdinalIgnoreCase);
}

private void ProcessSearch(IEnumerable<IRecord> records)
{
if (Save)
Expand Down