X Tutup
The Wayback Machine - https://web.archive.org/web/20221029031633/https://github.com/PowerShell/PowerShell/pull/5780
Skip to content
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

Show usage (short) help if command line parameter is wrong #5780

Merged
merged 2 commits into from Jan 5, 2018

Conversation

iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Jan 3, 2018

PR Summary

Close #4986

  • Show short help after an error message:
pwsh.exe -hhhhhhh
The argument '-hhhhhhh' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Usage: pwsh[.exe] [[-File] <filePath> [args]]
                  [-Command { - | <script-block> [-args <arg-array>]
                                | <string> [<CommandParameters>] } ]
                  [-ConfigurationName <string>] [-EncodedCommand <Base64EncodedCommand>]
                  [-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}]
                  [-Interactive] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
                  [-OutputFormat {Text | XML}] [-Version] [-WindowStyle <style>]

       pwsh[.exe] -h | -Help | -? | /?

PowerShell Online Help https://aka.ms/pscore6-docs

All parameters are case-insensitive.
  • Show full help message with pwsh -h

PR Checklist

Note: Please mark anything not applicable to this PR NA.

@iSazonov iSazonov self-assigned this Jan 3, 2018
@iSazonov iSazonov requested a review from SteveL-MSFT Jan 3, 2018
@iSazonov
Copy link
Collaborator Author

iSazonov commented Jan 3, 2018

CI AppVeyor temporary failed.

@@ -123,6 +123,21 @@ Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.</value>
</data>
Copy link
Member

@SteveL-MSFT SteveL-MSFT Jan 3, 2018

Choose a reason for hiding this comment

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

I don't like that we have a copy of the syntax. If we make updates in the future, we need to manually ensure that both sections are updated. Perhaps we can have the syntax (aka short help) just called HelpSyntax and the other one called ExtendedHelp. Now change the code where full help would have been shown shows HelpSyntax followed by ExtendedHelp.

Copy link
Collaborator Author

@iSazonov iSazonov Jan 4, 2018

Choose a reason for hiding this comment

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

If ExtendedHelp maybe second - UsageHelp or ShortHelp?

Copy link
Member

@SteveL-MSFT SteveL-MSFT Jan 4, 2018

Choose a reason for hiding this comment

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

UsageHelp sounds fine to me

Copy link
Collaborator Author

@iSazonov iSazonov Jan 4, 2018

Choose a reason for hiding this comment

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

Fixed.

@@ -394,6 +394,10 @@ private void ShowHelp()
Dbg.Assert(_helpText != null, "_helpText should not be null");
_hostUI.WriteLine("");
_hostUI.Write(_helpText);
if (_showExtendedHelp)
{
_hostUI.Write(ManagedEntranceStrings.ExtendedHelp);
Copy link
Member

@SteveL-MSFT SteveL-MSFT Jan 4, 2018

Choose a reason for hiding this comment

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

Shouldn't this show both UsageHelp and ExtendedHelp?

Copy link
Collaborator Author

@iSazonov iSazonov Jan 4, 2018

Choose a reason for hiding this comment

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

Line 396 already show UsageHelp.

Copy link
Member

@SteveL-MSFT SteveL-MSFT Jan 4, 2018

Choose a reason for hiding this comment

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

Got it!

@iSazonov iSazonov merged commit aaa567c into PowerShell:master Jan 5, 2018
@iSazonov iSazonov changed the title Show short help if command line parameter is wrong Show usage (short) help if command line parameter is wrong Jan 5, 2018
@iSazonov iSazonov deleted the add-short-help branch Jan 5, 2018
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance PowerShell full command line help
2 participants
X Tutup