8000 Add Path alias to -FilePath parameters and others for several commands by KevinMarquette · Pull Request #5817 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Add Path alias to -FilePath parameters and others for several commands #5817

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

Merged
merged 5 commits into from
Feb 27, 2018
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 @@ -1607,7 +1607,7 @@ public sealed class StartProcessCommand : PSCmdlet, IDisposable
/// </summary>
[Parameter(Mandatory = true, Position = 0)]
[ValidateNotNullOrEmpty]
[Alias("PSPath")]
[Alias("PSPath","Path")]
public string FilePath { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,7 @@ public string Name
/// </summary>
/// <value></value>
[Parameter(Position = 1, Mandatory = true)]
[Alias("Path")]
public string BinaryPathName
{
get { return binaryPathName; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public PSObject InputObject
/// FilePath parameter
/// </summary>
[Parameter(Mandatory = true, Position = 0, ParameterSetName = "File")]
[Alias("Path")]
public string FilePath
{
get { return _fileName; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public TraceOptions ListenerOption
/// </summary>
/// <value></value>
[Parameter(ParameterSetName = "optionsSet")]
[Alias("PSPath")]
[Alias("PSPath","Path")]
public string FilePath
{
get { return base.FileListener; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public TraceOptions ListenerOption
/// </summary>
/// <value></value>
[Parameter]
[Alias("PSPath")]
[Alias("PSPath","Path")]
public string FilePath
{
get { return base.FileListener; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public sealed class RegisterScheduledJobCommand : ScheduleJobCmdletBase
/// </summary>
[Parameter(Position = 1, Mandatory = true,
ParameterSetName = RegisterScheduledJobCommand.FilePathParameterSet)]
[Alias("Path")]
[ValidateNotNullOrEmpty]
public string FilePath
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public string Name
/// File path for script to be run in job.
/// </summary>
[Parameter(ParameterSetName = SetScheduledJobCommand.FilePathParameterSet)]
[Alias("Path")]
[ValidateNotNullOrEmpty]
public string FilePath
{
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.WSMan.Management/InvokeWSManAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public Uri ConnectionURI
/// via this input file
/// </summary>
[Parameter]
[Alias("Path")]
[ValidateNotNullOrEmpty]
public String FilePath
{
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.WSMan.Management/WSManInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ public Uri Dialect
/// via this input file
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Path")]
[ValidateNotNullOrEmpty]
public string FilePath
{
Expand Down Expand Up @@ -1258,6 +1259,7 @@ public Uri ConnectionURI
/// </summary>
[Parameter]
[ValidateNotNullOrEmpty]
[Alias("Path")]
public String FilePath
{
get { return filepath; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public SaveHelpCommand() : base(UpdatableHelpCommandType.SaveHelpCommand)
/// </summary>
[Parameter(Mandatory = true, Position = 0, ParameterSetName = PathParameterSetName)]
[ValidateNotNull]
[Alias("Path")]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] DestinationPath
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public string[] Module
/// </summary>
[Parameter(Position = 1, ParameterSetName = PathParameterSetName)]
[ValidateNotNull]
[Alias("Path")]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] SourcePath
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ Describe "Start-Process" -Tags @("Feature") {
# $process.ProcessName | Should Be "ping"
}

It "Should invoke correct path when used with Path alias argument" {
$process = Start-Process -Path $pingCommand -ArgumentList $pingParam -PassThru -RedirectStandardOutput "$TESTDRIVE/output"

$process.Length | Should Be 1
$process.Id | Should BeGreaterThan 1
}

It "Should wait for command completion if used with Wait argument" {
$process = Start-Process ping -ArgumentList $pingParam -Wait -PassThru -RedirectStandardOutput "$TESTDRIVE/output"
}
Expand Down Expand Up @@ -110,7 +117,7 @@ Describe "Start-Process" -Tags @("Feature") {
It "Should be able to use the -WhatIf switch without performing the actual action" {
$pingOutput = Join-Path $TestDrive "pingOutput.txt"
{ Start-Process -Wait $pingCommand -ArgumentList $pingParam -RedirectStandardOutput $pingOutput -WhatIf -ErrorAction Stop } | Should Not Throw
$pingOutput | Should Not Exist
$pingOutput | Should Not Exist
}

It "Should return null when using -WhatIf switch with -PassThru" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ Describe "Tee-Object DRT Unit Tests" -Tags "CI" {
$content | Should Be $expected
}

It "Positive File Test with Path parameter alias" {
$expected = "1", "2", "3"
$results = $expected | Tee-Object -Path $tempFile
$results.Length | Should be 3
$results | Should Be $expected
$content = Get-Content $tempFile
$content | Should Be $expected
}

It "Positive Variable Test" {
$expected = "1", "2", "3"
$varName = "teeObjectTestVar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ Describe "Trace-Command" -tags "CI" {
Get-Content $filePath -Raw | Should Match 'ParameterBinding Information'
}

It "Trace-Command using Path parameter alias" {
$null = New-Item $filePath -Force
Trace-Command -Name ParameterBinding -Command 'Get-PSDrive' -Path $filePath -Force
Get-Content $filePath -Raw | Should Match 'ParameterBinding Information'
}

It "Trace-Command contains wildcard characters" {
$a = Trace-Command -Name ParameterB* -Command 'get-alias'
$a.count | Should BeGreaterThan 0
Expand Down
0