public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Krzysztof Koch" <krzysztof.koch@arm.com>
To: <devel@edk2.groups.io>
Cc: <jaben.carsey@intel.com>, <ray.ni@intel.com>,
	<zhichao.gao@intel.com>, <Sami.Mujawar@arm.com>,
	<Matteo.Carlini@arm.com>, <nd@arm.com>
Subject: [PATCH v1 5/5] ShellPkg: acpiview: Make '-h' option not require a parameter
Date: Fri, 28 Jun 2019 09:57:00 +0100	[thread overview]
Message-ID: <20190628085700.17472-6-krzysztof.koch@arm.com> (raw)
In-Reply-To: <20190628085700.17472-1-krzysztof.koch@arm.com>

Make the -h command line option a binary flag. Now, colour
highlighting is enabled whenever this flag is set (stateless),
instead of being dependent on previous acpiview command
invocations.

By removing the parameter required with the -h flag the command
line parsing logic becomes simpler.

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
---

Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/commit/c3e78ab9d47f51e4c6a786a8813d1fa01685f0c9

Notes:
    v1:
    - turn the '-h' acpiview input option into a flag [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c                      | 30 ++------------------
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni |  6 ++--
 2 files changed, 5 insertions(+), 31 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 911b2da3dd9f19010d0f4993bcf017749cafb749..9feb2df2078f5aff41e1d39081fbb8cbc0bc32dd 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -34,7 +34,7 @@ STATIC BOOLEAN            mColourHighlighting;
 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-q", TypeFlag},
   {L"-d", TypeFlag},
-  {L"-h", TypeValue},
+  {L"-h", TypeFlag},
   {L"-l", TypeFlag},
   {L"-s", TypeValue},
   {NULL, TypeMax}
@@ -459,8 +459,6 @@ ShellCommandRunAcpiView (
   SHELL_STATUS       ShellStatus;
   LIST_ENTRY*        Package;
   CHAR16*            ProblemParam;
-  CONST CHAR16*      Temp;
-  CHAR8              ColourOption[8];
   SHELL_FILE_HANDLE  TmpDumpFileHandle;
 
   // Set Defaults
@@ -540,18 +538,6 @@ ShellCommandRunAcpiView (
         L"acpiview"
         );
       ShellStatus = SHELL_INVALID_PARAMETER;
-    } else if (ShellCommandLineGetFlag (Package, L"-h") &&
-               ShellCommandLineGetValue (Package, L"-h") == NULL) {
-        ShellPrintHiiEx (
-          -1,
-          -1,
-          NULL,
-          STRING_TOKEN (STR_GEN_NO_VALUE),
-          gShellAcpiViewHiiHandle,
-          L"acpiview",
-          L"-h"
-          );
-        ShellStatus = SHELL_INVALID_PARAMETER;
     } else if (ShellCommandLineGetFlag (Package, L"-d") &&
                !ShellCommandLineGetFlag (Package, L"-s")) {
         ShellPrintHiiEx (
@@ -566,18 +552,8 @@ ShellCommandRunAcpiView (
           );
         ShellStatus = SHELL_INVALID_PARAMETER;
     } else {
-      // Check if the colour option is set
-      Temp = ShellCommandLineGetValue (Package, L"-h");
-      if (Temp != NULL) {
-        UnicodeStrToAsciiStrS (Temp, ColourOption, sizeof (ColourOption));
-        if ((AsciiStriCmp (ColourOption, "ON") == 0) ||
-            (AsciiStriCmp (ColourOption, "TRUE") == 0)) {
-          SetColourHighlighting (TRUE);
-        } else if ((AsciiStriCmp (ColourOption, "OFF") == 0) ||
-                   (AsciiStriCmp (ColourOption, "FALSE") == 0)) {
-          SetColourHighlighting (FALSE);
-        }
-      }
+      // Turn on colour highlighting if requested
+      SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));
 
       // Surpress consistency checking if requested
       SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q"));
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
index 0d10b5debe470cb096cf414d0a0144fd3bde03ee..1f07b7ae20d474be67a433ff3774a508a5289318 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
@@ -30,7 +30,7 @@
 "Display ACPI Table information.\r\n"
 ".SH SYNOPSIS\r\n"
 " \r\n"
-"ACPIVIEW [[-?] | [[-l] | [-s AcpiTable [-d]]] [-q] [-h Highlight]]\r\n"
+"ACPIVIEW [[-?] | [[-l] | [-s AcpiTable [-d]]] [-q] [-h]]\r\n"
 " \r\n"
 ".SH OPTIONS\r\n"
 " \r\n"
@@ -40,9 +40,7 @@
 "         AcpiTable    : The required ACPI Table type.\r\n"
 "  -d - Generate a binary file dump of the specified AcpiTable.\r\n"
 "  -q - Quiet. Suppress errors and warnings. Disables consistency checks.\r\n"
-"  -h - Enable/Disable Colour Highlighting.\r\n"
-"         Highlight    : TRUE/ON enables highlighting;\r\n"
-"                        FALSE/OFF (default) disables highlighting.\r\n"
+"  -h - Enable colour highlighting.\r\n"
 "  -? - Show help.\r\n"
 " \r\n"
 ".SH DESCRIPTION\r\n"
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



  parent reply	other threads:[~2019-06-28  8:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28  8:56 [PATCH v1 0/5] Clean up acpiview input parameters Krzysztof Koch
2019-06-28  8:56 ` [PATCH v1 1/5] ShellPkg: acpiview: Remove '/?' from valid command line flags Krzysztof Koch
2019-06-28 11:06   ` [edk2-devel] " Alexei Fedorov
2019-06-28  8:56 ` [PATCH v1 2/5] ShellPkg: acpiview: Fix '\n\n' printing in Table Checksum reporting Krzysztof Koch
2019-06-28 11:06   ` [edk2-devel] " Alexei Fedorov
2019-06-28  8:56 ` [PATCH v1 3/5] ShellPkg: acpiview: Allow disabling consistency checks (-q flag) Krzysztof Koch
2019-06-28 11:06   ` [edk2-devel] " Alexei Fedorov
2019-06-28  8:56 ` [PATCH v1 4/5] ShellPkg: acpiview: Remove '-v' flag from allowed command line args Krzysztof Koch
2019-06-28 11:06   ` [edk2-devel] " Alexei Fedorov
2019-06-28  8:57 ` Krzysztof Koch [this message]
2019-06-28 11:05   ` [edk2-devel] [PATCH v1 5/5] ShellPkg: acpiview: Make '-h' option not require a parameter Alexei Fedorov
2019-06-28 11:07 ` [edk2-devel] [PATCH v1 0/5] Clean up acpiview input parameters Alexei Fedorov
2019-07-01  3:51 ` Gao, Zhichao
2019-07-02  8:44 ` Sami Mujawar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190628085700.17472-6-krzysztof.koch@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox