Skip to content

Change Get-Help behavior to return local help when no online help available #721

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

Merged
merged 15 commits into from
Sep 21, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ protected async Task HandleShowOnlineHelpRequest(
{
if (helpParams == null) { helpParams = "Get-Help"; }

PSCommand checkHelpPSCommand = new PSCommand();
checkHelpPSCommand.AddScript(CheckHelpScript, useLocalScope: true).AddArgument(helpParams);
PSCommand checkHelpPSCommand = new PSCommand()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to complain about the lack of var here, but technically the type here is the return type of the method. So all I feel is ambivalence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used PSCommand due to all the other comments about being explicit about the variable type 😁

Copy link
Contributor

@rjmholt rjmholt Sep 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wholly agree. In general you wouldn't lose explicit variable type constraints with var when the constructor is on the RHS of the assignment (var x = new Banana();), but here it's more nuanced because of a sort of Builder pattern scenario...

.AddScript(CheckHelpScript, useLocalScope: true)
.AddArgument(helpParams);
await editorSession.PowerShellContext.ExecuteCommand<PSObject>(checkHelpPSCommand, sendOutputToHost: true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a newline above the first await statement

await requestContext.SendResult(null);
}
Expand Down