Skip to content

Commit

Permalink
Adding -global switch and defaulting to search below current directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Staffan Gustafsson committed Mar 19, 2015
1 parent 1cccc51 commit 2e65238
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 28 deletions.
24 changes: 21 additions & 3 deletions PSEverything/PSEverything.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,35 @@
<Compile Include="SearchEverythingCommand.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="PSEverything.dll-Help.xml" />
<Content Include="PSEverything.dll-Help.xml">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="PSEverything.psd1" />
<Content Include="PSEverything.psd1" />
</ItemGroup>
<ItemGroup>
<Content Include="..\LICENSE">
<Link>LICENSE</Link>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
<Target Name="AfterBuild">
<ItemGroup>
<ModuleFiles Include="$(TargetPath)" />
<ModuleFiles Include="@(Content)" />
<ModuleFiles Include="dll\Everything*.dll" />
</ItemGroup>
<PropertyGroup>
<ModuleDir>$(TargetDir)\PSEverything</ModuleDir>
</PropertyGroup>
<MakeDir Directories="$(ModuleDir)" />
<Copy SourceFiles="@(ModuleFiles)" DestinationFolder="$(ModuleDir)" SkipUnchangedFiles="true" />
</Target>
-->
</Project>
66 changes: 52 additions & 14 deletions PSEverything/PSEverything.dll-Help.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<helpItems xmlns="http://msh" schema="maml">
<!-- Edited with: SAPIEN PowerShell HelpWriter 2015 v1.0.10-->
<!-- Generated by: SAPIEN PowerShell HelpWriter 2015 v1.0.10-->
Expand All @@ -19,7 +19,9 @@
</command:details>
<maml:description>
<maml:para>Search-Everyting Uses the Everything search engine from voidtools to perform near instant system wide searches of NTFS f
ile systems.</maml:para>
ile systems.

By default, Search-Everything limits the results to items below the current directory. Use the -Global switch to perform system wide searches.</maml:para>
</maml:description>
<command:syntax>
<!-- Parameter Sets-->
Expand All @@ -33,10 +35,10 @@ ile systems.</maml:para>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>QueryFilter</maml:name>
<maml:name>Filter</maml:name>
<maml:description>
<maml:para>Search filter in native &#39;Everything&#39; syntax.

See http://www.voidtools.com/support/everything/searching/ for more info.
Passed as-is to the search engine.

The search language that can be used is as follows:
Expand Down Expand Up @@ -170,6 +172,7 @@ Attribute Constants:
V Device</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Exclude</maml:name>
Expand All @@ -185,33 +188,37 @@ Attribute Constants:
</maml:description>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="pi">
<maml:name>PathInclude</maml:name>
<maml:description>
<maml:para>Specifies the filter for for paths to include</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="pe">
<maml:name>PathExclude</maml:name>
<maml:description>
<maml:para>Specifies the filter for for paths to exclude</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="fi">
<maml:name>FolderInclude</maml:name>
<maml:description>
<maml:para>Specifies the filter for for folders to include</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="fe">
<maml:name>FolderExclude</maml:name>
<maml:description>
<maml:para>Specifies the filter for for folders to exclude</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ParentCount</maml:name>
Expand Down Expand Up @@ -254,6 +261,15 @@ Attribute Constants:
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
<maml:name>Global</maml:name>
<maml:description>
<maml:para>Performs a global search, not limited by the current directory.
</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MatchWholeWord</maml:name>
<maml:description>
Expand Down Expand Up @@ -318,6 +334,15 @@ $ Matches the end of the filename
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
<maml:name>Global</maml:name>
<maml:description>
<maml:para>Performs a global search, not limited by the current directory.
</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>IncludeTotalCount</maml:name>
<maml:description>
Expand All @@ -344,8 +369,8 @@ followed by the results.</maml:para>
</command:syntax>
<command:parameters>
<!-- All Parameters-->
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>QueryFilter</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
<maml:name>Filter</maml:name>
<maml:description>
<maml:para>Search filter in native &#39;Everything&#39; syntax.

Expand Down Expand Up @@ -524,7 +549,7 @@ Attribute Constants:
</dev:type>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="pi">
<maml:name>PathInclude</maml:name>
<maml:description>
<maml:para>Specifies the filter for for paths to include</maml:para>
Expand All @@ -536,7 +561,7 @@ Attribute Constants:
</dev:type>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="pe">
<maml:name>PathExclude</maml:name>
<maml:description>
<maml:para>Specifies the filter for for paths to exclude</maml:para>
Expand All @@ -548,7 +573,7 @@ Attribute Constants:
</dev:type>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="fi">
<maml:name>FolderInclude</maml:name>
<maml:description>
<maml:para>Specifies the filter for for folders to include</maml:para>
Expand All @@ -560,7 +585,7 @@ Attribute Constants:
</dev:type>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="fe">
<maml:name>FolderExclude</maml:name>
<maml:description>
<maml:para>Specifies the filter for for folders to exclude</maml:para>
Expand Down Expand Up @@ -638,6 +663,19 @@ Attribute Constants:
</dev:type>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
<maml:name>Global</maml:name>
<maml:description>
<maml:para>Performs a global search, not limited by the current directory.
</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri/>
</dev:type>
<dev:defaultValue/>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MatchWholeWord</maml:name>
<maml:description>
Expand Down
Binary file modified PSEverything/PSEverything.psd1
Binary file not shown.
14 changes: 8 additions & 6 deletions PSEverything/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PSEverything")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyDescription("Powershell frontent for voidtools PSEverything")]
#if _DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif
[assembly: AssemblyCompany("PowerCode Consulting AB")]
[assembly: AssemblyProduct("PSEverything")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
Expand All @@ -33,4 +35,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
23 changes: 18 additions & 5 deletions PSEverything/SearchEverythingCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace PSEverything
public class SearchEverythingCommand : PSCmdlet
{
[Parameter(ParameterSetName = "default")]
public string QueryFilter { get; set; }
public string Filter { get; set; }

[Parameter(ParameterSetName = "default", Position = 1)]
public string[] Include { get; set; }
Expand All @@ -22,15 +22,19 @@ public class SearchEverythingCommand : PSCmdlet
[Parameter(ParameterSetName = "default")]
public string[] Extension { get; set; }

[Alias("pi")]
[Parameter(ParameterSetName = "default")]
public string[] PathInclude { get; set; }

[Alias("pe")]
[Parameter(ParameterSetName = "default")]
public string[] PathExclude { get; set; }

[Alias("fi")]
[Parameter(ParameterSetName = "default")]
public string[] FolderInclude { get; set; }

[Alias("fe")]
[Parameter(ParameterSetName = "default")]
public string[] FolderExclude { get; set; }

Expand All @@ -53,7 +57,10 @@ public class SearchEverythingCommand : PSCmdlet

[Parameter]
public SwitchParameter CaseSensitive { get; set; }


[Parameter]
public SwitchParameter Global { get; set; }

[Parameter(ParameterSetName = "default")]
public SwitchParameter MatchWholeWord { get; set; }

Expand All @@ -76,9 +83,9 @@ private string GetSearchString()

private void AddPatternFilter(StringBuilder searchBuilder)
{
if (!String.IsNullOrEmpty(QueryFilter))
if (!String.IsNullOrEmpty(Filter))
{
searchBuilder.Append(QueryFilter);
searchBuilder.Append(Filter);
}
}

Expand Down Expand Up @@ -111,7 +118,13 @@ private static void AddListFilter(StringBuilder searchBuilder, string filterName

private void AddPathFilter(StringBuilder searchBuilder)
{
AddListFilter(searchBuilder, "path:", PathInclude, PathExclude);
AddListFilter(searchBuilder, "path:", PathInclude, PathExclude);
if (!Global)
{
searchBuilder.Append(" path:");
searchBuilder.Append(SessionState.Path.CurrentFileSystemLocation.ProviderPath);
searchBuilder.Append('\\');
}
}

void AddFileFilter(StringBuilder searchBuilder)
Expand Down

0 comments on commit 2e65238

Please sign in to comment.