-
Notifications
You must be signed in to change notification settings - Fork 513
Feature request: Convert PowerShell command invocation to Splatting #898
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
Comments
You can do the same type of thing with editor commands and some of the EditorServices commands. For example this will splat whatever CommandAst is closest to your cursor. Register-EditorCommand -Name ConvertToSplatting -DisplayName 'Splat closest command' -ScriptBlock {
$ast = Find-Ast -AtCursor | Find-Ast -First -Ancestor { $_.GetType().Name -eq 'CommandAst' }
$ast | Set-ScriptExtent -Text (ConvertTo-Splatting $ast.Extent.Text)
} |
I think this issue is identical to that of #517. |
Thanks for pointing that out @kapilmb. Looks like SAPIEN implemented it into their editor based on my original release of |
I will work with it but the Register-EditorCommand does not seem to work for me. |
@pcgeek86 I am going to see if I can add this to the PowerShellEditorServices code. Do you mind if I use your splatting module's code? |
@PowerSchill Go or it :) |
It looks like Sapien implemented it in PowerShell Studio 2017: Service Release v5.4.141. |
Back before VSCode PowerShell was emerging, I was often using the PowerShell ISE to author PowerShell code. While writing PowerShell code, I typically call a PowerShell command, and then convert that to a Splatting invocation, which took a bit of manual effort. The more parameters a command invocation has the more effort it takes to manually convert the command invocation to Splatting syntax. This manual effort gets boring over time, and reduces the amount of time that I can focus on business logic.
To speed up that manual process, I wrote a PowerShell module called SplatHelper. It offers two commands:
I'd like to be able to achieve the same goal using VSCode.
Cheers,
Trevor Sullivan
https://trevorsullivan.net
The text was updated successfully, but these errors were encountered: