From 7c8e7960efbe5e5c9aff4cee128d054d4a8b5c9c Mon Sep 17 00:00:00 2001 From: jcarsey Date: Tue, 12 Mar 2013 20:54:07 +0000 Subject: =?UTF-8?q?ShellPkg:=20Rewrite=E2=80=99s=20Help.c=20to=20call=20th?= =?UTF-8?q?e=20ShellPrintHelp=20function.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also, adds a footer to the bottom of the “help” command to explain help switches. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Matt Stanbro Reviewed-by: Jaben Carsey Reviewed-by: Erik Bjorge git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14202 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c | 61 ++++++++------------- .../UefiShellLevel3CommandsLib.uni | Bin 42388 -> 42896 bytes 2 files changed, 22 insertions(+), 39 deletions(-) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c index 7e9d039f15..c4acc0b499 100644 --- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c +++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c @@ -1,7 +1,7 @@ /** @file Main file for Help shell level 3 function. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -48,9 +48,9 @@ ShellCommandRunHelp ( CHAR16 *SectionToGetHelpOn; CHAR16 *HiiString; BOOLEAN Found; - BOOLEAN HelpPage; + BOOLEAN PrintCommandText; - HelpPage = FALSE; + PrintCommandText = TRUE; ProblemParam = NULL; ShellStatus = SHELL_SUCCESS; OutText = NULL; @@ -111,7 +111,7 @@ ShellCommandRunHelp ( ASSERT(SectionToGetHelpOn == NULL); StrnCatGrow(&SectionToGetHelpOn, NULL, L"NAME", 0); } else { - HelpPage = TRUE; + PrintCommandText = FALSE; ASSERT(SectionToGetHelpOn == NULL); // // Get the section name for the given command name @@ -156,26 +156,13 @@ ShellCommandRunHelp ( // // We have a command to look for help on. // - Status = gEfiShellProtocol->GetHelpText(Node->CommandString, SectionToGetHelpOn, &OutText); - if (EFI_ERROR(Status) || OutText == NULL) { - if (Status == EFI_DEVICE_ERROR) { + Status = ShellPrintHelp(Node->CommandString, SectionToGetHelpOn, PrintCommandText); + if (Status == EFI_DEVICE_ERROR) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, Node->CommandString); - } else { + } else if (EFI_ERROR(Status)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, Node->CommandString); - } - ShellStatus = SHELL_NOT_FOUND; } else { - if (HelpPage) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_PAGE_COMMAND), gShellLevel3HiiHandle, OutText); - } else { - while (OutText[StrLen(OutText)-1] == L'\r' || OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') { - OutText[StrLen(OutText)-1] = CHAR_NULL; - } - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_COMMAND), gShellLevel3HiiHandle, Node->CommandString, OutText); - } - FreePool(OutText); - OutText = NULL; - Found = TRUE; + Found = TRUE; } } } @@ -183,30 +170,18 @@ ShellCommandRunHelp ( // Search the .man file for Shell applications (Shell external commands). // if (!Found) { - Status = gEfiShellProtocol->GetHelpText (CommandToGetHelpOn, SectionToGetHelpOn, &OutText); - if (EFI_ERROR(Status) || OutText == NULL) { + Status = ShellPrintHelp(CommandToGetHelpOn, SectionToGetHelpOn, FALSE); if (Status == EFI_DEVICE_ERROR) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, CommandToGetHelpOn); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, CommandToGetHelpOn); + } else if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CommandToGetHelpOn); } else { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CommandToGetHelpOn); - } - ShellStatus = SHELL_NOT_FOUND; - } else { - while (OutText[StrLen (OutText) - 1] == L'\r' || OutText[StrLen (OutText) - 1] == L'\n' || OutText[StrLen (OutText) - 1] == L' ') { - OutText[StrLen (OutText)-1] = CHAR_NULL; - } - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_COMMAND), gShellLevel3HiiHandle, CommandToGetHelpOn, OutText); - if (OutText != NULL) { - FreePool (OutText); - OutText = NULL; + Found = TRUE; } - Found = TRUE; - } } } - if (!Found && ShellStatus == SHELL_SUCCESS) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CommandToGetHelpOn); + if (!Found) { ShellStatus = SHELL_NOT_FOUND; } @@ -216,6 +191,14 @@ ShellCommandRunHelp ( ShellCommandLineFreeVarList (Package); } } + + if (CommandToGetHelpOn != NULL && StrCmp(CommandToGetHelpOn, L"*") == 0){ + // + // If '*' then the command entered was 'Help' without qualifiers, This footer + // provides additional info on help switches + // + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_FOOTER), gShellLevel3HiiHandle); + } if (CommandToGetHelpOn != NULL) { FreePool(CommandToGetHelpOn); } diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni index e75c468d84..55b2806098 100644 Binary files a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni and b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni differ -- cgit v1.2.3