FSharp.Management icon indicating copy to clipboard operation
FSharp.Management copied to clipboard

Is there any way to call powershell commands without the double backtick

Open voronoipotato opened this issue 8 years ago • 5 comments

So it's a bit inconvenient if I must always have the double backticks. I assume this is because of the dash. For example

PS.``Get-EventLog``(logName="Application", entryType=[|"Error"|], newest=2)

is it possible to change it to

PS.Get_EventLog(logName="Application", entryType=[|"Error"|], newest=2)

If yes, would it be very difficult to change? Thanks so much.

voronoipotato avatar Dec 03 '16 05:12 voronoipotato

Double backticks are added automatically somewhere inside providedtypes.fs, it's great and we should not touch this.

Replacing dashes with underscores is simple, but must be done with backward compatibility in mind, i.e. by adding a static parameter flag.

vasily-kirichenko avatar Dec 03 '16 07:12 vasily-kirichenko

I like backticks because it retain original command names and it clearly shows where you call PowerShell.

But if you (@voronoipotato) decide to implement this, please follow @vasily-kirichenko 's suggestion about the implementation

sergey-tihon avatar Dec 04 '16 08:12 sergey-tihon

Gotcha, that makes sense. I wonder if it would be best if both were available.PS.``Get-EventLog`` seems like it would be hard to convince my coworkers this is a normal thing. We use powershell at work, and I think it would be nice to be able to use powershell through F#. However I'm relatively new to F#, so perhaps this is one of those newbie complaints. Thanks

voronoipotato avatar Dec 06 '16 15:12 voronoipotato

But you can extend PS TP to have both options

The original one

type PS = PowerShellProvider< "Microsoft.PowerShell.Management;Microsoft.PowerShell.Core" >
PS.``Get-EventLog``(logName="Application", entryType=[|"Error"|], newest=2)

Without back-ticks

type PS = PowerShellProvider< "Microsoft.PowerShell.Management;Microsoft.PowerShell.Core", UseCamelCase = true >
PS.GetEventLog(logName="Application", entryType=[|"Error"|], newest=2)

sergey-tihon avatar Dec 20 '16 08:12 sergey-tihon

That sounds like the way to go. I'm going to try and figure out what the steps are to implement this. FAKE I think uses it's own way of hooking into PS that lacks the type providers. I might talk to the guys who make it and see if they would be interested in using the PS type providers because it seems like having intellisense would make things much easier.

voronoipotato avatar Dec 20 '16 15:12 voronoipotato