Skip to content

Commit

Permalink
(GH-663) Search just by id
Browse files Browse the repository at this point in the history
Similar to #453 which searches by exact id, you should also be able to
filter the search results where the filter is part of the id only.
  • Loading branch information
ferventcoder committed Mar 20, 2016
1 parent 5614014 commit 132825b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
.Add("e|exact",
"Exact - Only return packages with this exact name.",
option => configuration.ListCommand.Exact = option != null)
.Add("id|idonly|id-only",
"ByIdOnly - Only return packages with the filter being part of the id.",
option => configuration.ListCommand.ByIdOnly = option != null)
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ public ListCommandConfiguration()
public int? Page { get; set; }
public int PageSize { get; set; }
public bool Exact { get; set; }
public bool ByIdOnly { get; set; }
}

[Serializable]
Expand Down
5 changes: 5 additions & 0 deletions src/chocolatey/infrastructure.app/nuget/NugetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ private static IQueryable<IPackage> execute_package_search(ChocolateyConfigurati
results = results.Where(p => p.Id == configuration.Input);
}

if (configuration.ListCommand.ByIdOnly)
{
results = results.Where(p => p.Id.Contains(configuration.Input));
}

return results.OrderBy(p => p.Id);
}

Expand Down

0 comments on commit 132825b

Please sign in to comment.