diff --git a/src/Command/ImportMamlCommand.cs b/src/Command/ImportMamlCommand.cs index f25606a5..5b3f467e 100644 --- a/src/Command/ImportMamlCommand.cs +++ b/src/Command/ImportMamlCommand.cs @@ -23,6 +23,7 @@ public sealed class ImportMamlHelpCommand : PSCmdlet public string[] Path { get; set; } = new string[0]; [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "LiteralPath")] + [Alias("PSPath", "LP")] [ValidateNotNullOrEmpty] public string[] LiteralPath { get; set; } = new string[0]; diff --git a/src/Command/ImportMarkdownCommand.cs b/src/Command/ImportMarkdownCommand.cs index 10f1914b..8c7f3284 100644 --- a/src/Command/ImportMarkdownCommand.cs +++ b/src/Command/ImportMarkdownCommand.cs @@ -23,6 +23,7 @@ public sealed class ImportMarkdownHelpCommand : PSCmdlet public string[] Path { get; set; } = Array.Empty(); [Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")] + [Alias("PSPath", "LP")] [ValidateNotNullOrEmpty] public string[] LiteralPath { get; set; } = Array.Empty(); diff --git a/src/Command/ImportModuleFileCommand.cs b/src/Command/ImportModuleFileCommand.cs index 486ee6a5..dfc20519 100644 --- a/src/Command/ImportModuleFileCommand.cs +++ b/src/Command/ImportModuleFileCommand.cs @@ -23,6 +23,7 @@ public sealed class ImportMarkdownModuleFileCommand : PSCmdlet public string[] Path { get; set; } = Array.Empty(); [Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")] + [Alias("PSPath", "LP")] [ValidateNotNullOrEmpty] public string[] LiteralPath { get; set; } = Array.Empty(); diff --git a/src/Command/ImportYamlCommand.cs b/src/Command/ImportYamlCommand.cs index 296c6f5b..c27349e1 100644 --- a/src/Command/ImportYamlCommand.cs +++ b/src/Command/ImportYamlCommand.cs @@ -51,6 +51,7 @@ public string[] Path /// An array of literal paths to get the markdown metadata from. /// [Parameter(Mandatory = true, ParameterSetName = "LiteralPath")] + [Alias("PSPath", "LP")] public string[] LiteralPath { get diff --git a/src/Command/ImportYamlModuleFileCommand.cs b/src/Command/ImportYamlModuleFileCommand.cs index 2b3017f2..17bdeaa6 100644 --- a/src/Command/ImportYamlModuleFileCommand.cs +++ b/src/Command/ImportYamlModuleFileCommand.cs @@ -24,6 +24,7 @@ public sealed class ImportYamlModuleFileCommand : PSCmdlet public string[] Path { get; set; } = Array.Empty(); [Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")] + [Alias("PSPath", "LP")] [ValidateNotNullOrEmpty] public string[] LiteralPath { get; set; } = Array.Empty(); @@ -61,7 +62,7 @@ protected override void ProcessRecord() } continue; } - + if (YamlUtils.TryReadModuleFile(path, out ModuleFileInfo? moduleFileInfo, out Exception? deserializationError)) { WriteObject(moduleFileInfo); diff --git a/src/Command/Measure-PlatyPSMarkdown.cs b/src/Command/Measure-PlatyPSMarkdown.cs index 5b915f8f..7d4afd1c 100644 --- a/src/Command/Measure-PlatyPSMarkdown.cs +++ b/src/Command/Measure-PlatyPSMarkdown.cs @@ -23,6 +23,7 @@ public sealed class MeasurePlatyPSMarkdown : PSCmdlet public string[] Path { get; set; } = Array.Empty(); [Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")] + [Alias("PSPath", "LP")] [ValidateNotNullOrEmpty] public string[] LiteralPath { get; set; } = Array.Empty(); diff --git a/src/Command/Update-CommandHelp.cs b/src/Command/Update-CommandHelp.cs index eb1e41ce..309f2f04 100644 --- a/src/Command/Update-CommandHelp.cs +++ b/src/Command/Update-CommandHelp.cs @@ -27,6 +27,7 @@ public sealed class UpdateHelpCommand : PSCmdlet public string[] Path { get; set; } = Array.Empty(); [Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")] + [Alias("PSPath", "LP")] [ValidateNotNullOrEmpty] public string[] LiteralPath { get; set; } = Array.Empty(); @@ -65,7 +66,7 @@ protected override void ProcessRecord() var cmdInfo = SessionState.InvokeCommand.GetCommand(commandName, CommandTypes.Function|CommandTypes.Filter|CommandTypes.Cmdlet); if (cmdInfo is null) { - var err = new ErrorRecord(new CommandNotFoundException(commandName), "UpdateMarkdownCommandHelp,CommandNotFound", ErrorCategory.ObjectNotFound, commandName); + var err = new ErrorRecord(new CommandNotFoundException(commandName), "UpdateMarkdownCommandHelp,CommandNotFound", ErrorCategory.ObjectNotFound, commandName); err.ErrorDetails = new($"Did you import the module which includes '{commandName}'?"); WriteError(err); continue; @@ -74,7 +75,7 @@ protected override void ProcessRecord() var helpObjectFromCmdlet = new TransformCommand(transformSettings).Transform(cmdInfo); if (helpObjectFromCmdlet is null) { - var err = new ErrorRecord(new InvalidOperationException(commandName), "UpdateMarkdownCommandHelp,CmdletConversion", ErrorCategory.InvalidResult, commandName); + var err = new ErrorRecord(new InvalidOperationException(commandName), "UpdateMarkdownCommandHelp,CmdletConversion", ErrorCategory.InvalidResult, commandName); err.ErrorDetails = new($"Could not convert {commandName} to CommandHelp."); WriteError(err); continue; diff --git a/src/Command/Update-MarkdownCommandHelp.cs b/src/Command/Update-MarkdownCommandHelp.cs index 317f7bcb..de890af4 100644 --- a/src/Command/Update-MarkdownCommandHelp.cs +++ b/src/Command/Update-MarkdownCommandHelp.cs @@ -28,6 +28,7 @@ public sealed class UpdateMarkdownHelpCommand : PSCmdlet public string[] Path { get; set; } = Array.Empty(); [Parameter(Mandatory=true, ValueFromPipeline=true, ParameterSetName= "LiteralPath")] + [Alias("PSPath", "LP")] [ValidateNotNullOrEmpty] public string[] LiteralPath { get; set; } = Array.Empty(); @@ -91,7 +92,7 @@ protected override void ProcessRecord() var cmdInfo = PowerShellAPI.GetCommandInfo(commandName); if (cmdInfo is null) { - var err = new ErrorRecord(new CommandNotFoundException(commandName), "UpdateMarkdownCommandHelp,CommandNotFound", ErrorCategory.ObjectNotFound, commandName); + var err = new ErrorRecord(new CommandNotFoundException(commandName), "UpdateMarkdownCommandHelp,CommandNotFound", ErrorCategory.ObjectNotFound, commandName); err.ErrorDetails = new($"Did you import the module which includes '{commandName}'?"); WriteError(err); continue; @@ -100,7 +101,7 @@ protected override void ProcessRecord() var helpObjectFromCmdlet = new TransformCommand(transformSettings).Transform(cmdInfo.First()); if (helpObjectFromCmdlet is null) { - var err = new ErrorRecord(new InvalidOperationException(commandName), "UpdateMarkdownCommandHelp,CmdletConversion", ErrorCategory.InvalidResult, commandName); + var err = new ErrorRecord(new InvalidOperationException(commandName), "UpdateMarkdownCommandHelp,CmdletConversion", ErrorCategory.InvalidResult, commandName); err.ErrorDetails = new($"Could not convert {commandName} to CommandHelp."); WriteError(err); continue; diff --git a/src/Command/UpdateMarkdownModuleFile.cs b/src/Command/UpdateMarkdownModuleFile.cs index c34626c7..60d31cf0 100644 --- a/src/Command/UpdateMarkdownModuleFile.cs +++ b/src/Command/UpdateMarkdownModuleFile.cs @@ -26,6 +26,7 @@ public sealed class UpdateMarkdownModuleFileCommand : PSCmdlet public string Path { get; set; } = string.Empty; [Parameter(Mandatory = true, ParameterSetName = "literalpath")] + [Alias("PSPath", "LP")] public string LiteralPath { get; set; } = string.Empty; [Parameter(ValueFromPipeline = true, Mandatory = true, Position = 1)] diff --git a/test/Pester/Cmdlet.Tests.ps1 b/test/Pester/Cmdlet.Tests.ps1 index 4a61bb12..cefe31ce 100644 --- a/test/Pester/Cmdlet.Tests.ps1 +++ b/test/Pester/Cmdlet.Tests.ps1 @@ -13,7 +13,10 @@ Describe "Miscellaneous cmdlet tests" { } ) { param ($cmdlet) - $cmdlet.Parameters['LiteralPath'] | Should -Not -BeNullOrEmpty + $param = $cmdlet.Parameters['LiteralPath'] + $param | Should -Not -BeNullOrEmpty + $param.Aliases | Should -Contain "PSPath" + $param.Aliases | Should -Contain "LP" } } @@ -88,7 +91,7 @@ Describe "Miscellaneous cmdlet tests" { Import-Module Microsoft.PowerShell.Archive if (! $IsWindows) { $skipTest = $true - return + return } $OutputPath = "$TestDrive\CabTesting"