Skip to content

Commit 566fea4

Browse files
authored
Update the cmdlet parameters according to feedback. (#14217)
1 parent d78b04a commit 566fea4

File tree

3 files changed

+8
-44
lines changed

3 files changed

+8
-44
lines changed

tools/Az.Tools.Predictor/Az.Tools.Predictor/Commands/DisableAzPredictor.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
1615
using System.Text;
1716
using System.Management.Automation;
1817

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

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

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

50-
if (Session == SessionParameterValue.All)
48+
if (AllSession.IsPresent)
5149
{
5250
_ = 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\"");
5351
}

tools/Az.Tools.Predictor/Az.Tools.Predictor/Commands/EnableAzPredictor.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
1615
using System.Text;
1716
using System.Management.Automation;
1817

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

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

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

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

tools/Az.Tools.Predictor/Az.Tools.Predictor/Commands/SessionParameterValue.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)