Skip to content

Add code fix or formatting rule to generate splatted parameters from command invocation #517

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

Closed
mpearon opened this issue Feb 28, 2017 · 10 comments
Labels
Area-Code Formatting Issue-Enhancement A feature request (enhancement).

Comments

@mpearon
Copy link

mpearon commented Feb 28, 2017

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!

System Details

  • Operating system name and version: Windows 10, 1511
  • VS Code version: v1.9.1
  • PowerShell extension version: v0.9.0
  • Output from $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                                                                                                        

@daviwil
Copy link
Contributor

daviwil commented Feb 28, 2017

Yep, I think we could add this as a command in the editor. What do you think @kapilmb?

@daviwil daviwil added the Issue-Enhancement A feature request (enhancement). label Feb 28, 2017
@kapilmb
Copy link

kapilmb commented Feb 28, 2017

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?

@daviwil
Copy link
Contributor

daviwil commented Feb 28, 2017

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 ;)

@Jaykul
Copy link

Jaykul commented Feb 28, 2017

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?

@daviwil
Copy link
Contributor

daviwil commented Feb 28, 2017

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 daviwil added this to the June 2017 milestone May 17, 2017
@daviwil daviwil changed the title Auto-splatting Feature Code fix or formatting rule to generate splatted parameters from command invocation May 17, 2017
@daviwil daviwil changed the title Code fix or formatting rule to generate splatted parameters from command invocation Add code fix or formatting rule to generate splatted parameters from command invocation May 17, 2017
@daviwil daviwil modified the milestones: June 2017, July 2017 Jul 11, 2017
@mpearon
Copy link
Author

mpearon commented Sep 7, 2017

@daviwil - Has there been any more planning and/or movement on this project?

@daviwil
Copy link
Contributor

daviwil commented Sep 7, 2017

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.

@daviwil daviwil modified the milestones: July 2017, Future Oct 26, 2017
@TylerLeonhardt TylerLeonhardt modified the milestone: Future May 24, 2018
@TylerLeonhardt
Copy link
Member

@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.

@ghost
Copy link

ghost commented May 27, 2019

Can't get EditorServicesCommandSuite to work with the latest vscode and PowerShell extension

is there a new setting or config that I am missing?

@TylerLeonhardt
Copy link
Member

@snewfie can you open an issue over in https://github.com/SeeminglyScience/EditorServicesCommandSuite and provide as much info as you can?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Code Formatting Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

6 participants