Skip to content

Commit

Permalink
Add option to include/exclude previews to workload search version com…
Browse files Browse the repository at this point in the history
…mand Fixes #43890 (#45149)
  • Loading branch information
marcpopMSFT authored Nov 26, 2024
2 parents e0e804a + 6ba0aa9 commit 5e1bc3c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal class WorkloadSearchVersionsCommand : WorkloadCommandBase
private readonly string _workloadSetOutputFormat;
private readonly FileBasedInstaller _installer;
private readonly string _workloadVersion;
private readonly bool _includePreviews;

public WorkloadSearchVersionsCommand(
ParseResult result,
Expand Down Expand Up @@ -64,6 +65,10 @@ public WorkloadSearchVersionsCommand(
);

_workloadVersion = result.GetValue(WorkloadSearchVersionsCommandParser.WorkloadVersionArgument);

_includePreviews = result.HasOption(WorkloadSearchVersionsCommandParser.IncludePreviewsOption) ?
result.GetValue(WorkloadSearchVersionsCommandParser.IncludePreviewsOption) :
new SdkFeatureBand(_sdkVersion).IsPrerelease;
}

public override int Execute()
Expand All @@ -76,7 +81,7 @@ public override int Execute()
List<string> versions;
try
{
versions = PackageDownloader.GetLatestPackageVersions(packageId, _numberOfWorkloadSetsToTake, packageSourceLocation: null, includePreview: !string.IsNullOrWhiteSpace(_sdkVersion.Prerelease))
versions = PackageDownloader.GetLatestPackageVersions(packageId, _numberOfWorkloadSetsToTake, packageSourceLocation: null, includePreview: _includePreviews)
.GetAwaiter().GetResult()
.Select(version => WorkloadSetVersion.FromWorkloadSetPackageVersion(featureBand, version.ToString()))
.ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ internal static class WorkloadSearchVersionsCommandParser
Description = LocalizableStrings.FormatOptionDescription
};

public static readonly CliOption<bool> IncludePreviewsOption = new("--include-previews");

private static readonly CliCommand Command = ConstructCommand();

public static CliCommand GetCommand()
Expand All @@ -36,6 +38,7 @@ private static CliCommand ConstructCommand()
command.Arguments.Add(WorkloadVersionArgument);
command.Options.Add(FormatOption);
command.Options.Add(TakeOption);
command.Options.Add(IncludePreviewsOption);

TakeOption.Validators.Add(optionResult =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public SdkFeatureBand(ReleaseVersion version)
}
}

public bool IsPrerelease => !string.IsNullOrEmpty(_featureBand.Prerelease);
public int Major => _featureBand.Major;
public int Minor => _featureBand.Minor;

Expand Down

0 comments on commit 5e1bc3c

Please sign in to comment.