PowerShell Studio Request - Format Script Enhancements

Post feature requests, product enhancement ideas, and other product-specific suggestions here. Do not post bug reports.
Forum rules
Do not post any licensing information in this forum.
This topic is 8 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
PsCustomObject
Posts: 137
Last visit: Mon Mar 18, 2024 3:11 am

PowerShell Studio Request - Format Script Enhancements

Post by PsCustomObject »

Hello all,

just recently purchased PSS 2015 and I fell in love with the features and the ability to easily create GUIs which can be redistributed but thought propose couple of enhancement/ideas that I loved in the previous product I was using.

Remove Aliases

I know there is an option and a keybord shortcut but yet it would be nice if the Format Script button could expand any alias in the script automatically, I know this could sound minor but as it is best practice not to use aliases in scripts I think it would be nice to have this automatically fixed by PSS.

Enforce proper use of single vs double quotes

I think the title says it all, generally speaking it is a good habit to use single quotes by default unless we want PowerShell to make changes to the text or expand a variable within quotes.

Again this is not essential but reinforces good habits and would make it easier to stick to them.

Better formatting for long line of commands

I think an example is better than thousand words, I'm from Switzerland and the CSV delimeter over here is ";" rather than "," so someitmes it is handy to format output in place with a command similar to the following
  1. foreach ($csv in $reportFile) { (Get-Content $csv) | ForEach-Object -Process { $_ -replace ',', ';' } |Set-Content $csv }}
It will run and it is readable but I think this is much nicer/easier to read and follow
  1. foreach ($csv in $reportFile)
  2.     {
  3.         (Get-Content $csv) |
  4.         ForEach-Object -Process {
  5.             $_ -replace ',', ';'
  6.         } |
  7.         Set-Content $csv
  8.     }
Again non essential but when you're dealing with many scripts somtime written by other people who ignore (or are to lazy to follow) best practices it makes it easier to have your IDE fix human shortcomings.

Hope the above will make sense and if any further detail can be helpful please let me know and I'll be more than glad to elaborate further.

If I had to make a choice the last function/option is the one I would like to see implemented but guess that is a matter of personal taste.

Cheers L.

*EDIT* The script review rules I'm talking about are coming from here https://www.powershellgallery.com/packa ... On/0.6.2.0 which can be imported into standard Windows ISE.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: PowerShell Studio Request - Format Script Enhancements

Post by davidc »

Remove Aliases

You can expand all aliases by pressing [Ctrl + Shift + A]. We are looking at adding an option to expand aliases into the code formatter.

Enforce proper use of single vs double quotes

We definitely are look into incorporating the Script Analyzer into the editor.

Better formatting for long line of commands

The formatter always leaves open and closed brackets that are on the same line as is. I can add a feature request to the wishlist for an option to change this behavior.
It looks like you would also like an option to insert a newline after the pipe character? Is this correct?

David
David
SAPIEN Technologies, Inc.
User avatar
PsCustomObject
Posts: 137
Last visit: Mon Mar 18, 2024 3:11 am

Re: PowerShell Studio Request - Format Script Enhancements

Post by PsCustomObject »

First of all thanks for taking your time to read/consider and answer the post, I really appreciate it.
davidc wrote:
You can expand all aliases by pressing [Ctrl + Shift + A]. We are looking at adding an option to expand aliases into the code formatter.
Yep thanks I was aware about the keyboard shortcut and getting used to it, as I said this is not essential but for lazy people like me having the IDE handling this automatically would be nice.
davidc wrote: Enforce proper use of single vs double quotes

We definitely are look into incorporating the Script Analyzer into the editor.
This is great indeed and looking forward it!
davidc wrote:
The formatter always leaves open and closed brackets that are on the same line as is. I can add a feature request to the wishlist for an option to change this behavior.
It looks like you would also like an option to insert a newline after the pipe character? Is this correct?

David
Yes you got the point.

Again many thanks for considering this!

L.
This topic is 8 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked