Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.WinGet.Configuration messages #3242

Merged
merged 11 commits into from
May 18, 2023
Merged
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ apfn
apicontract
apiset
appinstallertest
applic
appname
argumentlist
ARMNT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Microsoft.WinGet.Client.Engine.Commands
using System.Management.Automation;
using Microsoft.Management.Deployment;
using Microsoft.WinGet.Client.Engine.Commands.Common;
using Microsoft.WinGet.Client.Engine.Extensions;
using Microsoft.WinGet.Client.Engine.Helpers;
using Microsoft.WinGet.Client.Engine.Properties;
using Microsoft.WinGet.Client.Engine.PSObjects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
namespace Microsoft.WinGet.Configuration.Cmdlets
{
using System.Management.Automation;
using System.Threading;
using Microsoft.PowerShell;
using Microsoft.WinGet.Configuration.Engine.Commands;
using Microsoft.WinGet.Configuration.Helpers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace Microsoft.WinGet.Configuration.Cmdlets
[Cmdlet(VerbsLifecycle.Invoke, "WinGetConfiguration")]
public sealed class InvokeWinGetConfigurationCmdlet : PSCmdlet
{
private bool acceptedAgreements = false;

/// <summary>
/// Gets or sets the configuration set.
/// </summary>
Expand All @@ -31,23 +33,27 @@ public sealed class InvokeWinGetConfigurationCmdlet : PSCmdlet
/// <summary>
/// Gets or sets a value indicating whether to accept the configuration agreements.
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter AcceptConfigurationAgreements { get; set; }

/// <summary>
/// Pre-processing operations.
/// </summary>
protected override void BeginProcessing()
{
// TODO: if not agrementsAccepted print message with ShouldContinue.
this.acceptedAgreements = ConfigurationCommand.ConfirmConfigurationProcessing(this, this.AcceptConfigurationAgreements.ToBool());
}

/// <summary>
/// Starts to apply the configuration and wait for it to complete.
/// </summary>
protected override void ProcessRecord()
{
var configCommand = new ConfigurationCommand(this);
configCommand.Apply(this.Set);
if (this.acceptedAgreements)
{
var configCommand = new ConfigurationCommand(this);
configCommand.Apply(this.Set);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Microsoft.WinGet.Configuration.Cmdlets
[Cmdlet(VerbsLifecycle.Start, "WinGetConfiguration")]
public sealed class StartWinGetConfigurationCmdlet : PSCmdlet
{
private bool acceptedAgreements = false;

/// <summary>
/// Gets or sets the configuration set.
/// </summary>
Expand All @@ -30,23 +32,27 @@ public sealed class StartWinGetConfigurationCmdlet : PSCmdlet
/// <summary>
/// Gets or sets a value indicating whether to accept the configuration agreements.
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter AcceptConfigurationAgreements { get; set; }

/// <summary>
/// Pre-processing operations.
/// </summary>
protected override void BeginProcessing()
{
// TODO: if not agrementsAccepted print message with ShouldContinue.
this.acceptedAgreements = ConfigurationCommand.ConfirmConfigurationProcessing(this, this.AcceptConfigurationAgreements.ToBool());
}

/// <summary>
/// Starts to apply the configuration and wait for it to complete.
/// </summary>
protected override void ProcessRecord()
{
var configCommand = new ConfigurationCommand(this, canWriteToStream: false);
configCommand.StartApply(this.Set);
if (this.acceptedAgreements)
{
var configCommand = new ConfigurationCommand(this);
configCommand.StartApply(this.Set);
}
}
}
}
Loading