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

Update the cmdlet parameters according to feedback #14217

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Text;
using System.Management.Automation;

Expand All @@ -29,11 +28,10 @@ public sealed class DisableAzPredictor : PSCmdlet
};

/// <summary>
/// Gets and sets the session that this cmdlet applies to.
/// Indicates whether it's applied to all sessions.
/// </summary>
[Parameter(Position = 0)]
[ValidateSet(nameof(SessionParameterValue.All), nameof(SessionParameterValue.Current))]
public SessionParameterValue Session { get; set; }
[Parameter(Mandatory = false)]
public SwitchParameter AllSession { get; set; }

/// <summary>
/// Indicates whether the user would like to receive output.
Expand All @@ -47,7 +45,7 @@ protected override void ProcessRecord()
var scriptToRun = new StringBuilder();
var _ = scriptToRun.Append(DisableAzPredictor._DisableStatements[0]);

if (Session == SessionParameterValue.All)
if (AllSession.IsPresent)
{
_ = scriptToRun.Append(";Write-Host \"To disable Az Predictor, please edit your profile ($PROFILE) and remove the following lines:`nImport-Module Az.Tools.Predictor`nSet-PSReadLineOption -PredictionSource HistoryAndPlugin`n\"");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Text;
using System.Management.Automation;

Expand All @@ -30,11 +29,10 @@ public sealed class EnableAzPredictor : PSCmdlet
};

/// <summary>
/// Gets and sets the session that this cmdlet applies to.
/// Indicates whether it's applied to all sessions.
/// </summary>
[Parameter(Position = 0)]
[ValidateSet(nameof(SessionParameterValue.All), nameof(SessionParameterValue.Current))]
public SessionParameterValue Session { get; set; }
[Parameter(Mandatory = false)]
public SwitchParameter AllSession { get; set; }

/// <summary>
/// Indicates whether the user would like to receive output.
Expand All @@ -48,7 +46,7 @@ protected override void ProcessRecord()
var scriptToRun = new StringBuilder();
var _ = scriptToRun.Append(EnableAzPredictor._EnableStatements[1]);

if (Session == SessionParameterValue.All)
if (AllSession.IsPresent)
{
_ = scriptToRun.Append($";Add-Content -Path $PROFILE -Value \"`n{string.Join("`n", EnableAzPredictor._EnableStatements)}\" -NoNewline -Encoding UTF8 -Force")
.Append($";Write-Host \"User profile ($PROFILE) has been updated.`n\"");
Expand Down

This file was deleted.