mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Show usage (short) help if command line parameter is wrong (#5780)
Show usage (short) help if command line parameter is wrong Show extended (full) help message with pwsh -h Split Help message on Usage and Extended
This commit is contained in:
@@ -394,6 +394,10 @@ namespace Microsoft.PowerShell
|
||||
Dbg.Assert(_helpText != null, "_helpText should not be null");
|
||||
_hostUI.WriteLine("");
|
||||
_hostUI.Write(_helpText);
|
||||
if (_showExtendedHelp)
|
||||
{
|
||||
_hostUI.Write(ManagedEntranceStrings.ExtendedHelp);
|
||||
}
|
||||
_hostUI.WriteLine("");
|
||||
}
|
||||
|
||||
@@ -536,6 +540,7 @@ namespace Microsoft.PowerShell
|
||||
else if (MatchSwitch(switchKey, "help", "h") || MatchSwitch(switchKey, "?", "?"))
|
||||
{
|
||||
_showHelp = true;
|
||||
_showExtendedHelp = true;
|
||||
_abortStartup = true;
|
||||
}
|
||||
else if (MatchSwitch(switchKey, "noexit", "noe"))
|
||||
@@ -955,7 +960,7 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
WriteCommandLineError(
|
||||
string.Format(CultureInfo.CurrentCulture, CommandLineParameterParserStrings.ArgumentFileDoesNotExist, args[i]),
|
||||
showBanner: false);
|
||||
showHelp: true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1164,6 +1169,7 @@ namespace Microsoft.PowerShell
|
||||
private string _configurationName;
|
||||
private PSHostUserInterface _hostUI;
|
||||
private bool _showHelp;
|
||||
private bool _showExtendedHelp;
|
||||
private bool _showBanner = true;
|
||||
private bool _noInteractive;
|
||||
private string _bannerText;
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Microsoft.PowerShell
|
||||
var formattedBanner = string.Format(CultureInfo.InvariantCulture, banner, PSVersionInfo.GitCommitId);
|
||||
exitCode = Microsoft.PowerShell.ConsoleShell.Start(
|
||||
formattedBanner,
|
||||
ManagedEntranceStrings.ShellHelp,
|
||||
ManagedEntranceStrings.UsageHelp,
|
||||
args);
|
||||
}
|
||||
catch (System.Management.Automation.Host.HostException e)
|
||||
|
||||
@@ -124,7 +124,7 @@ Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
https://aka.ms/pscore6-docs
|
||||
Type 'help' to get help.</value>
|
||||
</data>
|
||||
<data name="ShellHelp" xml:space="preserve">
|
||||
<data name="UsageHelp" xml:space="preserve">
|
||||
<value>Usage: pwsh[.exe] [[-File] <filePath> [args]]
|
||||
[-Command { - | <script-block> [-args <arg-array>]
|
||||
| <string> [<CommandParameters>] } ]
|
||||
@@ -137,7 +137,10 @@ Type 'help' to get help.</value>
|
||||
|
||||
PowerShell Online Help https://aka.ms/pscore6-docs
|
||||
|
||||
All parameters are case-insensitive.
|
||||
All parameters are case-insensitive.</value>
|
||||
</data>
|
||||
<data name="ExtendedHelp" xml:space="preserve">
|
||||
<value>
|
||||
|
||||
-Command | -c
|
||||
Executes the specified commands (and any parameters) as though they were typed
|
||||
|
||||
Reference in New Issue
Block a user