[anaconda:rhel7/master] Add option help text for --image and --dirinstall flags (#1056791)

mulhern amulhern at redhat.com
Wed Jan 29 14:53:58 UTC 2014


Resolves: rhbz#1056791

The help text is not added in-line, because if more complete help text
were added in-line, the source in anaconda would get very hard to read.
Also, the help text is a lot easier to format out-of-line.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 anaconda                        |  6 ++++--
 pyanaconda/anaconda_optparse.py | 31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/anaconda b/anaconda
index 8ec0363..2e4228c 100755
--- a/anaconda
+++ b/anaconda
@@ -284,8 +284,10 @@ def parseOptions(argv=None, cmdline=None):
     op.add_option("--nomount", dest="rescue_nomount", action="store_true", default=False)
     op.add_option("--updates", dest="updateSrc", action="store", type="string")
     op.add_option("--dlabel", action="store_true", default=False)
-    op.add_option("--image", action="append", dest="images", default=[])
-    op.add_option("--dirinstall", action="store_true", default=False)
+    op.add_option("--image", action="append", dest="images", default=[],
+       metavar="IMAGE_SPEC", help=op.help_text("image"))
+    op.add_option("--dirinstall", action="store_true", default=False,
+       help=op.help_text("dirinstall"))
     op.add_option("--memcheck", action="store_true", default=True)
     op.add_option("--nomemcheck", action="store_false", dest="memcheck")
     op.add_option("--leavebootorder", action="store_true", default=False)
diff --git a/pyanaconda/anaconda_optparse.py b/pyanaconda/anaconda_optparse.py
index 37f4b86..fb1c1a8 100644
--- a/pyanaconda/anaconda_optparse.py
+++ b/pyanaconda/anaconda_optparse.py
@@ -124,3 +124,34 @@ class AnacondaOptionParser(OptionParser):
             values = self.get_default_values()
         v = self.parse_boot_cmdline(cmdline, values)
         return OptionParser.parse_args(self, args, v)
+
+    def help_text(self, option):
+        """
+        Returns the help text corresponding to the given command-line option.
+        If no help text is available, returns the empty string.
+
+        :param str option: The name of the option
+
+        :rtype: str
+        """
+
+        helps = {
+           "dirinstall":
+           "Use the device mounted at /mnt/sysimage as the installation "
+           "destination. The --dirinstall and --image options are mutually "
+           "exclusive.",
+           "image":
+           "Specification of disk image file to be used as installation "
+           "destination. IMAGE_SPEC must have format <path>[:<name>] where "
+           "<path> specifies the path of an image file and an optional <name> "
+           "component is used to identify the disk during installation. "
+           "<path> must be a local path but it may be relative or absolute. "
+           "If <name> is not specified, a name is synthesized from the "
+           "basename of <path>. <name> may not contain a colon or a slash. "
+           "This option may be used multiple times to specify multiple disk "
+           "images. It is an error to specify the same <path> twice or to use "
+           "duplicate names. The --image and --dirinstall options are "
+           "mutually exclusive."
+           }
+
+        return helps[option] if option in helps else ""
-- 
1.8.3.1



More information about the anaconda-patches mailing list