]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Add ShellPrintHelp function to ShellLib.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 4 Mar 2013 21:54:02 +0000 (21:54 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 4 Mar 2013 21:54:02 +0000 (21:54 +0000)
This function allows for easier access to printing standard command help.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Matt Stanbro <Matthew.A.Stanbro@intel.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14159 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Include/Library/ShellLib.h
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index a1b534bd3ec360d08de629cf5c8652243399299f..eefa030ad12cc7cf50e57021dac5be3aed35ba72 100644 (file)
@@ -1357,4 +1357,23 @@ ShellDeleteFileByName(
   IN CONST CHAR16               *FileName\r
   );\r
 \r
+/**\r
+  Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.\r
+\r
+  @param[in] CommandToGetHelpOn  Pointer to a string containing the command name of help file to be printed.\r
+  @param[in] SectionToGetHelpOn  Pointer to the section specifier(s).\r
+  @param[in] PrintCommandText    If TRUE, prints the command followed by the help content, otherwise prints \r
+                                 the help content only.\r
+  @retval EFI_DEVICE_ERROR       The help data format was incorrect.\r
+  @retval EFI_NOT_FOUND          The help data could not be found.\r
+  @retval EFI_SUCCESS            The operation was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellPrintHelp (\r
+  IN CONST CHAR16     *CommandToGetHelpOn,\r
+  IN CONST CHAR16     *SectionToGetHelpOn,\r
+  IN BOOLEAN          PrintCommandText\r
+  );\r
+\r
 #endif // __SHELL_LIB__\r
index 4c09069f5a41b08ec8f78408e5f6735ac40140bc..6b985ed64e842ef7c8df4aa7c30dc46d3e47ab32 100644 (file)
@@ -4060,6 +4060,66 @@ ShellFileHandleReadLine(
   return (Status);\r
 }\r
 \r
+/**\r
+  Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.\r
+\r
+  @param[in] CommandToGetHelpOn  Pointer to a string containing the command name of help file to be printed.\r
+  @param[in] SectionToGetHelpOn  Pointer to the section specifier(s).\r
+  @param[in] PrintCommandText    If TRUE, prints the command followed by the help content, otherwise prints \r
+                                 the help content only.\r
+  @retval EFI_DEVICE_ERROR       The help data format was incorrect.\r
+  @retval EFI_NOT_FOUND          The help data could not be found.\r
+  @retval EFI_SUCCESS            The operation was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellPrintHelp (\r
+  IN CONST CHAR16     *CommandToGetHelpOn,\r
+  IN CONST CHAR16     *SectionToGetHelpOn,\r
+  IN BOOLEAN          PrintCommandText\r
+  )\r
+{\r
+       EFI_STATUS          Status;\r
+       CHAR16              *OutText;\r
+         \r
+       OutText = NULL;\r
+       \r
+  //\r
+  // Get the string to print based\r
+  //\r
+       Status = gEfiShellProtocol->GetHelpText (CommandToGetHelpOn, SectionToGetHelpOn, &OutText);\r
+  \r
+  //\r
+  // make sure we got a valid string\r
+  //\r
+  if (EFI_ERROR(Status)){\r
+    return Status;\r
+       } \r
+  if (OutText == NULL || StrLen(OutText) == 0) {\r
+    return EFI_NOT_FOUND;  \r
+       }\r
+  \r
+  //\r
+  // Chop off trailing stuff we dont need\r
+  //\r
+  while (OutText[StrLen(OutText)-1] == L'\r' || OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {\r
+    OutText[StrLen(OutText)-1] = CHAR_NULL;\r
+  }\r
+  \r
+  //\r
+  // Print this out to the console\r
+  //\r
+  if (PrintCommandText) {\r
+    ShellPrintEx(-1, -1, L"%H%-14s%N- %s\r\n", CommandToGetHelpOn, OutText);\r
+  } else {\r
+    ShellPrintEx(-1, -1, L"%N%s\r\n", OutText);\r
+  }\r
+  \r
+  SHELL_FREE_NON_NULL(OutText);\r
+\r
+       return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   Function to delete a file by name\r
   \r