Skip to content

Commit b9c080b

Browse files
Add alias for LiteralPath parameter for all cmdlets (#767)
1 parent 5df6b75 commit b9c080b

10 files changed

+19
-7
lines changed

src/Command/ImportMamlCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public sealed class ImportMamlHelpCommand : PSCmdlet
2323
public string[] Path { get; set; } = new string[0];
2424

2525
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "LiteralPath")]
26+
[Alias("PSPath", "LP")]
2627
[ValidateNotNullOrEmpty]
2728
public string[] LiteralPath { get; set; } = new string[0];
2829

src/Command/ImportMarkdownCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public sealed class ImportMarkdownHelpCommand : PSCmdlet
2323
public string[] Path { get; set; } = Array.Empty<string>();
2424

2525
[Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")]
26+
[Alias("PSPath", "LP")]
2627
[ValidateNotNullOrEmpty]
2728
public string[] LiteralPath { get; set; } = Array.Empty<string>();
2829

src/Command/ImportModuleFileCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public sealed class ImportMarkdownModuleFileCommand : PSCmdlet
2323
public string[] Path { get; set; } = Array.Empty<string>();
2424

2525
[Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")]
26+
[Alias("PSPath", "LP")]
2627
[ValidateNotNullOrEmpty]
2728
public string[] LiteralPath { get; set; } = Array.Empty<string>();
2829

src/Command/ImportYamlCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public string[] Path
5151
/// An array of literal paths to get the markdown metadata from.
5252
/// </summary>
5353
[Parameter(Mandatory = true, ParameterSetName = "LiteralPath")]
54+
[Alias("PSPath", "LP")]
5455
public string[] LiteralPath
5556
{
5657
get

src/Command/ImportYamlModuleFileCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public sealed class ImportYamlModuleFileCommand : PSCmdlet
2424
public string[] Path { get; set; } = Array.Empty<string>();
2525

2626
[Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")]
27+
[Alias("PSPath", "LP")]
2728
[ValidateNotNullOrEmpty]
2829
public string[] LiteralPath { get; set; } = Array.Empty<string>();
2930

@@ -61,7 +62,7 @@ protected override void ProcessRecord()
6162
}
6263
continue;
6364
}
64-
65+
6566
if (YamlUtils.TryReadModuleFile(path, out ModuleFileInfo? moduleFileInfo, out Exception? deserializationError))
6667
{
6768
WriteObject(moduleFileInfo);

src/Command/Measure-PlatyPSMarkdown.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public sealed class MeasurePlatyPSMarkdown : PSCmdlet
2323
public string[] Path { get; set; } = Array.Empty<string>();
2424

2525
[Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")]
26+
[Alias("PSPath", "LP")]
2627
[ValidateNotNullOrEmpty]
2728
public string[] LiteralPath { get; set; } = Array.Empty<string>();
2829

src/Command/Update-CommandHelp.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public sealed class UpdateHelpCommand : PSCmdlet
2727
public string[] Path { get; set; } = Array.Empty<string>();
2828

2929
[Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")]
30+
[Alias("PSPath", "LP")]
3031
[ValidateNotNullOrEmpty]
3132
public string[] LiteralPath { get; set; } = Array.Empty<string>();
3233

@@ -65,7 +66,7 @@ protected override void ProcessRecord()
6566
var cmdInfo = SessionState.InvokeCommand.GetCommand(commandName, CommandTypes.Function|CommandTypes.Filter|CommandTypes.Cmdlet);
6667
if (cmdInfo is null)
6768
{
68-
var err = new ErrorRecord(new CommandNotFoundException(commandName), "UpdateMarkdownCommandHelp,CommandNotFound", ErrorCategory.ObjectNotFound, commandName);
69+
var err = new ErrorRecord(new CommandNotFoundException(commandName), "UpdateMarkdownCommandHelp,CommandNotFound", ErrorCategory.ObjectNotFound, commandName);
6970
err.ErrorDetails = new($"Did you import the module which includes '{commandName}'?");
7071
WriteError(err);
7172
continue;
@@ -74,7 +75,7 @@ protected override void ProcessRecord()
7475
var helpObjectFromCmdlet = new TransformCommand(transformSettings).Transform(cmdInfo);
7576
if (helpObjectFromCmdlet is null)
7677
{
77-
var err = new ErrorRecord(new InvalidOperationException(commandName), "UpdateMarkdownCommandHelp,CmdletConversion", ErrorCategory.InvalidResult, commandName);
78+
var err = new ErrorRecord(new InvalidOperationException(commandName), "UpdateMarkdownCommandHelp,CmdletConversion", ErrorCategory.InvalidResult, commandName);
7879
err.ErrorDetails = new($"Could not convert {commandName} to CommandHelp.");
7980
WriteError(err);
8081
continue;

src/Command/Update-MarkdownCommandHelp.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public sealed class UpdateMarkdownHelpCommand : PSCmdlet
2828
public string[] Path { get; set; } = Array.Empty<string>();
2929

3030
[Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")]
31+
[Alias("PSPath", "LP")]
3132
[ValidateNotNullOrEmpty]
3233
public string[] LiteralPath { get; set; } = Array.Empty<string>();
3334

@@ -91,7 +92,7 @@ protected override void ProcessRecord()
9192
var cmdInfo = PowerShellAPI.GetCommandInfo(commandName);
9293
if (cmdInfo is null)
9394
{
94-
var err = new ErrorRecord(new CommandNotFoundException(commandName), "UpdateMarkdownCommandHelp,CommandNotFound", ErrorCategory.ObjectNotFound, commandName);
95+
var err = new ErrorRecord(new CommandNotFoundException(commandName), "UpdateMarkdownCommandHelp,CommandNotFound", ErrorCategory.ObjectNotFound, commandName);
9596
err.ErrorDetails = new($"Did you import the module which includes '{commandName}'?");
9697
WriteError(err);
9798
continue;
@@ -100,7 +101,7 @@ protected override void ProcessRecord()
100101
var helpObjectFromCmdlet = new TransformCommand(transformSettings).Transform(cmdInfo.First());
101102
if (helpObjectFromCmdlet is null)
102103
{
103-
var err = new ErrorRecord(new InvalidOperationException(commandName), "UpdateMarkdownCommandHelp,CmdletConversion", ErrorCategory.InvalidResult, commandName);
104+
var err = new ErrorRecord(new InvalidOperationException(commandName), "UpdateMarkdownCommandHelp,CmdletConversion", ErrorCategory.InvalidResult, commandName);
104105
err.ErrorDetails = new($"Could not convert {commandName} to CommandHelp.");
105106
WriteError(err);
106107
continue;

src/Command/UpdateMarkdownModuleFile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public sealed class UpdateMarkdownModuleFileCommand : PSCmdlet
2626
public string Path { get; set; } = string.Empty;
2727

2828
[Parameter(Mandatory = true, ParameterSetName = "literalpath")]
29+
[Alias("PSPath", "LP")]
2930
public string LiteralPath { get; set; } = string.Empty;
3031

3132
[Parameter(ValueFromPipeline = true, Mandatory = true, Position = 1)]

test/Pester/Cmdlet.Tests.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ Describe "Miscellaneous cmdlet tests" {
1313
}
1414
) {
1515
param ($cmdlet)
16-
$cmdlet.Parameters['LiteralPath'] | Should -Not -BeNullOrEmpty
16+
$param = $cmdlet.Parameters['LiteralPath']
17+
$param | Should -Not -BeNullOrEmpty
18+
$param.Aliases | Should -Contain "PSPath"
19+
$param.Aliases | Should -Contain "LP"
1720
}
1821
}
1922

@@ -88,7 +91,7 @@ Describe "Miscellaneous cmdlet tests" {
8891
Import-Module Microsoft.PowerShell.Archive
8992
if (! $IsWindows) {
9093
$skipTest = $true
91-
return
94+
return
9295
}
9396

9497
$OutputPath = "$TestDrive\CabTesting"

0 commit comments

Comments
 (0)