PowerShellEditorServices
PowerShellEditorServices copied to clipboard
Standardize host process command line parameter handling
Currently we use a rather simplistic means for parsing parameters sent to the PSES host process. We need a more acceptable design for reading parameters passed from the command line. This would also be a good time to change our parameter naming and symbols to be "PowerShell style" like powershell.exe and powershell_ise.exe.
A typical host invocation currently looks like this:
Microsoft.PowerShell.EditorServices.Host.exe /debugAdapter /logPath:SomePath.log /logLevel:Verbose
In the future I would expect it'd look like this:
Microsoft.PowerShell.EditorServices.Host.exe -DebugAdapter -LogPath SomePath.log -LogLevel Verbose
The parsing of such a format should not need to take all of PowerShell's parameter structures into account, just the bare minimum to expose a consistent interface. For parameters like -DebugAdapter which act like a switch, we could simplify parsing by pre-specifying the expected parameters to help the parser determine whether to expect a value for a particular parameter.
Another possibility could be to use PowerShell's parser to parse the entire command invocation string (including the exe path) so that we can use the AST or tokens to influence our interpretation of the parameters.
Like PowerShell.exe, I would expect the CL parsing to accept both - and /.
use PowerShell's parser to parse the entire command invocation string
The parameters are currently not complex enough to warrant that IMO. Plus I think most PowerShell users have different expectations for exe parameter parsing (including PowerShell.exe) vs PowerShell command parsing.
Interesting, didn't realize powershell.exe accepted / as well. Good to know that the expecations are different there. I looked at the ISE's parsing code and noticed it got more complicated because it needs to accept an array for -Files so I was hoping to avoid doing the same kind of work for the host. We probably won't ever need to accept arrays or objects, though.