Skip to content

Commit

Permalink
(GH-670) Search enhancements
Browse files Browse the repository at this point in the history
- exclude broken packages - this only filters out packages with a
  failing test status. It won't filter results from feeds that don't
  have that information available.
- download cache available - this option will only return results from
  the community feed.
- approved only - this option will only return results from the
  community feed.
  • Loading branch information
ferventcoder committed Mar 25, 2016
1 parent 528bcb1 commit 887a876
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ $allcommands = " --debug --verbose --force --noop --help --accept-license --conf
$proInstallUpgradeOptions = " --skip-download-cache --use-download-cache --skip-virus-check --virus-check --virus-positives-minimum="

$commandOptions = @{
list = "--lo --pre --exact --by-id-only --id-starts-with --source='' --user= --password= --local-only --prerelease --include-programs --page= --page-size= --order-by-popularity" + $allcommands
search = "--pre --exact --by-id-only --id-starts-with --source='' --user= --password= --local-only --prerelease --include-programs --page= --page-size= --order-by-popularity" + $allcommands
list = "--lo --pre --exact --by-id-only --id-starts-with --approved-only --not-broken --source='' --user= --password= --local-only --prerelease --include-programs --page= --page-size= --order-by-popularity --download-cache-only" + $allcommands
search = "--pre --exact --by-id-only --id-starts-with --approved-only --not-broken --source='' --user= --password= --local-only --prerelease --include-programs --page= --page-size= --order-by-popularity --download-cache-only" + $allcommands
install = "-y -whatif -? --pre --version= --params='' --install-arguments='' --override-arguments --ignore-dependencies --source='' --source='windowsfeatures' --source='webpi' --user= --password= --prerelease --forcex86 --not-silent --package-parameters='' --allow-downgrade --force-dependencies --skip-automation-scripts --allow-multiple-versions --ignore-checksums" + $allcommands + $proInstallUpgradeOptions
pin = "--name= --version= -?" + $allcommands
outdated = "-? --source='' --user= --password=" + $allcommands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ public static void set_environment_variables(ChocolateyConfiguration config)

private static void set_licensed_options(ChocolateyConfiguration config, ChocolateyLicense license, ConfigFileSettings configFileSettings)
{
config.Information.IsLicensedVersion = license.is_licensed_version();

if (license.AssemblyLoaded)
{
Type licensedConfigBuilder = license.Assembly.GetType(ApplicationParameters.LicensedConfigurationBuilder, throwOnError: false, ignoreCase: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
option => configuration.ListCommand.IdStartsWith = option != null)
.Add("order-by-popularity",
"OrderByPopularity - Sort by package results by popularity.",
option => configuration.ListCommand.OrderByPopularity = option != null)
option => configuration.ListCommand.OrderByPopularity = option != null)
.Add("approved-only",
"ApprovedOnly - Only return approved packages - this option will filter out results not from the community repository.",
option => configuration.ListCommand.ApprovedOnly = option != null)
.Add("download-cache|download-cache-only",
"DownloadCacheAvailable - Only return packages that have a download cache available - this option will filter out results not from the community repository.",
option => configuration.ListCommand.DownloadCacheAvailable = option != null)
.Add("not-broken",
"NotBroken - Only return packages that are not failing testing - this option only filters out failing results from the community feed. It will not filter against other sources. ",
option => configuration.ListCommand.NotBroken = option != null)
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public sealed class InformationCommandConfiguration
public bool IsInteractive { get; set; }
public bool IsUserAdministrator { get; set; }
public bool IsProcessElevated { get; set; }
public bool IsLicensedVersion { get; set; }
}

[Serializable]
Expand Down Expand Up @@ -359,6 +360,9 @@ public ListCommandConfiguration()
public bool ByIdOnly { get; set; }
public bool IdStartsWith { get; set; }
public bool OrderByPopularity { get; set; }
public bool ApprovedOnly { get; set; }
public bool DownloadCacheAvailable { get; set; }
public bool NotBroken { get; set; }
}

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

if (configuration.ListCommand.ApprovedOnly)
{
results = results.Where(p => p.IsApproved);
}

if (configuration.ListCommand.DownloadCacheAvailable)
{
results = results.Where(p => p.IsDownloadCacheAvailable);
}

if (configuration.ListCommand.NotBroken)
{
results = results.Where(p => (p.IsDownloadCacheAvailable && configuration.Information.IsLicensedVersion) || p.PackageTestResultStatus != "Failing");
}

if (configuration.AllVersions)
{
if (isRemote)
Expand Down

0 comments on commit 887a876

Please sign in to comment.