File help.patch of Package open-ovf

Index: open-ovf-0.1/py/scripts/mkovf
===================================================================
--- open-ovf-0.1.orig/py/scripts/mkovf
+++ open-ovf-0.1/py/scripts/mkovf
@@ -22,6 +22,8 @@ from ovf import validation
 from ovf.commands import cli
 from ovf.commands import VERSION_STR
 
+USAGE = "usage: mkovf command -f <Ovf file path> [options]"
+
 def initOVF(ovfFile, options=None):
     """
     This function creates an empy OVF.
@@ -580,7 +582,7 @@ def validateOVF(ovfFile, options):
 
 def main():
     #The version=VERSION_STR is the version of the OVF.
-    cliParser = cli.CLI(commands, common, version=VERSION_STR)
+    cliParser = cli.CLI(commands, common, usage=USAGE, version=VERSION_STR)
     command, options, args = cliParser.parseArgs()
 
     ovfFile = None
@@ -630,20 +632,21 @@ commands = {
            "required": True
          },
          { "flags" : [ "-s", "--size" ],
-           "parms" : { "dest" : "size","help":"The size of the file. If none"+
-                       " is given the size will be acquired for that file." }},
+           "parms" : { "dest" : "size","help":"The size of the file in bytes."+
+                       " If none is given the size will be acquired for that"+
+                       " file." }},
 
          { "flags" : [ "-c", "--compression" ],
            "parms" : { "dest" : "compression","help": "Defines the"+
-                    " compression of the file if any. If none is given the"+
-                    " compression shall be determined. Specifying 'identity',"+
+                    " compression of the file, if any. If none is given the"+
+                    " compression shall be determined. Specifying 'identity'"+
                     " states that no compression is used. If the href is an"+
-                    " HTTP or HTTPS ,URI, then the compression may be"+
+                    " HTTP or HTTPS URI, then the compression may be"+
                     " specified by the HTTP server." }},
 
          { "flags" : [ "-C", "--chunksize" ],
            "parms" : { "dest" : "chunksize","help":"Defines the chunksize for"+
-                    " the file if any." }}
+                    " the file, if any." }}
       )
    },
    "disk" : {
@@ -664,23 +667,32 @@ commands = {
            "required": True
          },
          { "flags" : [ "-r", "--fileRef" ],
-           "parms" : { "dest" : "fileRef","help" : "File reference." }},
+           "parms" : { "dest" : "fileRef","help" : "File reference.  The"+
+                    " ovfID of corresponding File element in references"+
+                    " section."}
+         },
          { "flags" : [ "-s", "--size" ],
-           "parms" : { "dest" : "populatedSize","help": "Populated Size." }},
+           "parms" : { "dest" : "populatedSize","help": "Populated size"+
+                    " in bytes."}
+         },
          { "flags" : [ "-u", "--capacityAlloc" ],
            "parms" : { "dest" : "capacityAllocUnits","help" : "Capacity"+
-                    " allocation Units." }},
+                    " allocation Units." }
+         },
          { "flags" : [ "-p", "--parentRef" ],
-           "parms" : { "dest" : "parentRef","help" :"Parent ref. In order to"+
-                    " specify this the parent must have already been "+
-                    "specified." }},
-        { "flags" : [ "-m", "--info" ],
+           "parms" : { "dest" : "parentRef","help" :"Reference to parent"+
+                    " diskID. In order to specify this the parent must"+
+                    " have already been specified." }
+         },
+         { "flags" : [ "-m", "--info" ],
            "parms" : { "dest" : "info","help" : "The information to describe"+
-                    " the section." }},
-        { "flags" : [ "-y"],
+                    " the section." }
+         },
+         { "flags" : [ "-y"],
            "parms" : { "dest" : "infoID","help" : "The id of the section's"+
-                    " information." }},
-        { "flags" : [ "-q", "--notrequired"],
+                    " information." }
+         },
+         { "flags" : [ "-q", "--notrequired"],
            "parms" : { "dest" : "required", "action": "store_false",
                     "default": True,
                     "help" : "Defines if the section is not required."},
Index: open-ovf-0.1/py/ovf/commands/cli.py
===================================================================
--- open-ovf-0.1.orig/py/ovf/commands/cli.py
+++ open-ovf-0.1/py/ovf/commands/cli.py
@@ -98,15 +98,19 @@ class CLI:
         @rtype: str
         """
 
-        parser = OptionParser(self.usage, version = self.version)
+        parser = OptionParser(self.usage, version=self.version,
+                              add_help_option=False)
         for opt in self.commands:
             parser.add_option("--" + opt, help = self.commands[opt]['help'],
                  action="store_const", const=opt, dest="cmd")
 
+        parser.add_option("-h", "--help", action="store_const",
+                          const="help", dest="cmd")
+
         try:
             cmdStr = args[0]
         except IndexError:
-            parser.print_help()
+            self.printHelp(args)
             sys.exit(2)
 
         options, args = parser.parse_args([ cmdStr ])
@@ -158,13 +162,46 @@ class CLI:
         """
 
         # if args is not specified use sys.argv
-        args = args or sys.argv[1:]
+        args = args or sys.argv
+
+        cmd = self._parseCommand(args[1:])
+        if cmd == 'help':
+            self.printHelp(args)
+            sys.exit(0)
 
-        cmd = self._parseCommand(args)
-        options, pArgs = self._parseSubcommand(cmd, args[1:])
+        options, pArgs = self._parseSubcommand(cmd, args[2:])
 
         return cmd, options, pArgs
 
+    def printHelp(self, args):
+
+        if len(args) <= 2 or \
+                (len(args) > 2 and not self.commands.has_key(args[2])):
+            print self.usage
+            print "\nCommands:"
+            print "  --help, -h\n    Show this help message and exit"
+            for cmd in self.commands:
+                print "  --%s" % cmd
+                print "    %s" % self.commands[cmd]['help']
+        else:
+            print "usage: %s --%s [options]" % (args[0], args[2])
+            print self.commands[args[2]]['help']
+            print "\nOptions:"
+            for carg in self.common:
+                flags = "  "
+                for f in carg['flags']:
+                    flags += f + ","
+                print flags.rsplit(',', 1)[0]
+                print "    %s" % carg['parms']['help']
+            cargs = self.commands[args[2]]['args']
+            for carg in cargs:
+                flags = "  "
+                for f in carg['flags']:
+                    flags += f + ", "
+                print flags.rsplit(',', 1)[0]
+                print "    %s" % carg['parms']['help']
+
+
 class MultipleNodeError(Exception):
     """
     This error class will be used to print information about multiple
openSUSE Build Service is sponsored by