-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enable -WorkingDirectory parameter to pwsh #6612
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
Changes from all commits
47342e6
cc5910d
0867221
c2feccb
e02a875
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,6 +132,7 @@ Type 'help' to get help.</value> | |
| [-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}] | ||
| [-Interactive] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile] | ||
| [-OutputFormat {Text | XML}] [-Version] [-WindowStyle <style>] | ||
| [-WorkingDirectory <directoryPath>] | ||
|
|
||
| pwsh[.exe] -h | -Help | -? | /? | ||
|
|
||
|
|
@@ -249,6 +250,12 @@ All parameters are case-insensitive.</value> | |
|
|
||
| -WindowStyle | -w | ||
| Sets the window style to Normal, Minimized, Maximized or Hidden. | ||
|
|
||
| -WorkingDirectory | -wd | ||
| Sets the working directory at the start of PowerShell given a valid PowerShell directory path. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably should mention that this "valid PowerShell directory path" is used as a LiteralPath.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this true for all providers?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be true for all well written providers
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sense add this to the help or online help? |
||
| Executing `Set-Location -LiteralPath <path>` at startup. | ||
|
|
||
| Example: pwsh -WorkingDirectory ~ | ||
| </value> | ||
| </data> | ||
| </root> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -561,6 +561,44 @@ foo | |
| } | ||
| } | ||
| } | ||
|
|
||
| Context "-WorkingDirectory parameter" { | ||
| BeforeAll { | ||
| $folderName = (New-Guid).ToString() + " test"; | ||
| New-Item -Path ~/$folderName -ItemType Directory | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For installer use, I think we want to test
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder - is this a suitable place for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intent is to validate a path understood by the FileSystemProvider which abstracts
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why we place FileSystemProvider tests in ConsoleHost.Tests.ps1.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation for this parameter is that any file system provider path is accepted, and |
||
| $ExitCodeBadCommandLineParameter = 64 | ||
| } | ||
|
|
||
| AfterAll { | ||
| Remove-Item ~/$folderName -Force -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| It "Can set working directory to '<value>'" -TestCases @( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to have a case where $value has a space in directory name.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add those cases |
||
| @{ value = "~" ; expectedPath = $((Get-Item ~).FullName) }, | ||
| @{ value = "~/$folderName"; expectedPath = $((Get-Item ~/$folderName).FullName) }, | ||
| @{ value = "~\$folderName"; expectedPath = $((Get-Item ~\$folderName).FullName) } | ||
| ) { | ||
| param($value, $expectedPath) | ||
| $output = & $powershell -WorkingDirectory "$value" -Command "`$pwd.Path" | ||
| $output | Should -BeExactly $expectedPath | ||
| } | ||
|
|
||
| It "Can use '<parameter>' to set working directory" -TestCases @( | ||
| @{ parameter = '-workingdirectory' }, | ||
| @{ parameter = '-wd' }, | ||
| @{ parameter = '-wo' } | ||
| ) { | ||
| param($parameter) | ||
| $output = & $powershell $parameter ~ -Command "`$pwd.Path" | ||
| $output | Should -BeExactly $((Get-Item ~).FullName) | ||
| } | ||
|
|
||
| It "Error case if -WorkingDirectory isn't given argument as last on command line" { | ||
| $output = & $powershell -WorkingDirectory | ||
| $LASTEXITCODE | Should -Be $ExitCodeBadCommandLineParameter | ||
| $output | Should -Not -BeNullOrEmpty | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Describe "WindowStyle argument" -Tag Feature { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like
-woshould also be mentioned in the help text.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pwsh parameters work the same as PowerShell parameters in that if there is sufficient difference in the name, it will figure it out. So
-wiwill work for-windowstyleand-wowill work for-workingdirectory, although-wis reserved for-windowstyle. So for that reason, I don't think it needs to be added explicitly to the help.