Sapien's PowerShell Studio has a feature that will allow you to convert single line commands to be splatted.
For a visual of what I'm talking about, click here
This would be a great enhancement, I think!
$PSVersionTable:PSVersion 5.0.10586.672
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.672
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Yep, I think we could add this as a command in the editor. What do you think @kapilmb?
Or a code-action, perhaps?
Not sure about the timeline though. I would say this will be a great post-1.0 addition. What do you say?
It could be a suggested code action if the line was longer than a certain length, for sure. However, I think it'd be nice if this was something that could be invoked anytime on a command in a script file.
We could try it post-1.0 unless @Jaykul gets to it first ;)
If there was a rule that gave a warning on lines longer than 120char, but an information on all commands with more than one parameter ... would that be enough to let you surface it the way you're imagining, @daviwil?
Yeah, that could work. For the "invoke any time" approach, I think we'd basically just run the rule on the current script line (including any backticked lines following that) and see if a marker gets returned. If yes, apply the correction.
@daviwil - Has there been any more planning and/or movement on this project?
We've been occupied with other work lately so we haven't been able to focus on this particular issue. I think the ideal way to add this feature would be through an extension module. Thankfully @SeeminglyScience has done just that :)
https://github.com/SeeminglyScience/EditorServicesCommandSuite
Check out the Demo section for a GIF that demonstrates its features.
@SeeminglyScience did a great job in EditorServicesCommandSuite and we shouldn't stomp on his toes in that.
That said, @Jaykul hinted at something that this would make an awesome PSScriptAnalyzer rule.
I'll close this since folks should either grab ESCS or refer to the issue in PSSA that Rob will post here.
Can't get EditorServicesCommandSuite to work with the latest vscode and PowerShell extension
is there a new setting or config that I am missing?
@snewfie can you open an issue over in https://github.com/SeeminglyScience/EditorServicesCommandSuite and provide as much info as you can?
Most helpful comment
Yep, I think we could add this as a command in the editor. What do you think @kapilmb?