summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2013-03-04 21:54:02 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2013-03-04 21:54:02 +0000
commit365aa98a5dfba45b7ecfe04495cb28e9e05d2a45 (patch)
tree3a13e86c98a2ae6829c09483c944c819ac6f0c95 /ShellPkg
parentfb2ae5fdb5207233e9be8f73d552860d9169fa8e (diff)
ShellPkg: Add ShellPrintHelp function to ShellLib.
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
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Include/Library/ShellLib.h19
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c60
2 files changed, 79 insertions, 0 deletions
diff --git a/ShellPkg/Include/Library/ShellLib.h b/ShellPkg/Include/Library/ShellLib.h
index a1b534bd3..eefa030ad 100644
--- a/ShellPkg/Include/Library/ShellLib.h
+++ b/ShellPkg/Include/Library/ShellLib.h
@@ -1357,4 +1357,23 @@ ShellDeleteFileByName(
IN CONST CHAR16 *FileName
);
+/**
+ Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.
+
+ @param[in] CommandToGetHelpOn Pointer to a string containing the command name of help file to be printed.
+ @param[in] SectionToGetHelpOn Pointer to the section specifier(s).
+ @param[in] PrintCommandText If TRUE, prints the command followed by the help content, otherwise prints
+ the help content only.
+ @retval EFI_DEVICE_ERROR The help data format was incorrect.
+ @retval EFI_NOT_FOUND The help data could not be found.
+ @retval EFI_SUCCESS The operation was successful.
+**/
+EFI_STATUS
+EFIAPI
+ShellPrintHelp (
+ IN CONST CHAR16 *CommandToGetHelpOn,
+ IN CONST CHAR16 *SectionToGetHelpOn,
+ IN BOOLEAN PrintCommandText
+ );
+
#endif // __SHELL_LIB__
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 4c09069f5..6b985ed64 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -4061,6 +4061,66 @@ ShellFileHandleReadLine(
}
/**
+ Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.
+
+ @param[in] CommandToGetHelpOn Pointer to a string containing the command name of help file to be printed.
+ @param[in] SectionToGetHelpOn Pointer to the section specifier(s).
+ @param[in] PrintCommandText If TRUE, prints the command followed by the help content, otherwise prints
+ the help content only.
+ @retval EFI_DEVICE_ERROR The help data format was incorrect.
+ @retval EFI_NOT_FOUND The help data could not be found.
+ @retval EFI_SUCCESS The operation was successful.
+**/
+EFI_STATUS
+EFIAPI
+ShellPrintHelp (
+ IN CONST CHAR16 *CommandToGetHelpOn,
+ IN CONST CHAR16 *SectionToGetHelpOn,
+ IN BOOLEAN PrintCommandText
+ )
+{
+ EFI_STATUS Status;
+ CHAR16 *OutText;
+
+ OutText = NULL;
+
+ //
+ // Get the string to print based
+ //
+ Status = gEfiShellProtocol->GetHelpText (CommandToGetHelpOn, SectionToGetHelpOn, &OutText);
+
+ //
+ // make sure we got a valid string
+ //
+ if (EFI_ERROR(Status)){
+ return Status;
+ }
+ if (OutText == NULL || StrLen(OutText) == 0) {
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Chop off trailing stuff we dont need
+ //
+ while (OutText[StrLen(OutText)-1] == L'\r' || OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {
+ OutText[StrLen(OutText)-1] = CHAR_NULL;
+ }
+
+ //
+ // Print this out to the console
+ //
+ if (PrintCommandText) {
+ ShellPrintEx(-1, -1, L"%H%-14s%N- %s\r\n", CommandToGetHelpOn, OutText);
+ } else {
+ ShellPrintEx(-1, -1, L"%N%s\r\n", OutText);
+ }
+
+ SHELL_FREE_NON_NULL(OutText);
+
+ return EFI_SUCCESS;
+}
+
+/**
Function to delete a file by name
@param[in] FileName Pointer to file name to delete.