`gmg reprocess available --action-help` now tells you processor arguments!
authorChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 9 Aug 2013 18:56:23 +0000 (13:56 -0500)
committerRodney Ewing <ewing.rj@gmail.com>
Fri, 16 Aug 2013 22:30:15 +0000 (15:30 -0700)
Every reprocessing action possible can inform you of its command line
argument stuff!  Is that awesome or what?

mediagoblin/gmg_commands/reprocess.py
mediagoblin/media_types/image/processing.py
mediagoblin/processing/__init__.py

index d6ac99ac4b94c3edc0677cf2a9cdfaedfdffe97b..70163928c404fdcae709e82eca2f8c6926e88f87 100644 (file)
@@ -37,6 +37,11 @@ def reprocess_parser_setup(subparser):
         "id_or_type",
         help="Media id or media type to check")
 
+    available_parser.add_argument(
+        "--action-help",
+        action="store_true",
+        help="List argument help for each action available")
+
     
     ############################################
     # run command (TODO: and bulk_run command??)
@@ -221,13 +226,22 @@ def available(args):
         processors = manager.list_eligible_processors(media_entry)
 
     print "Available processors:"
-    print "---------------------"
+    print "====================="
 
-    for processor in processors:
-        if processor.description:
-            print " - %s: %s" % (processor.name, processor.description)
-        else:
-            print " - %s" % processor.name
+    if args.action_help:
+        for processor in processors:
+            print processor.name
+            print "-" * len(processor.name)
+
+            parser = processor.generate_parser()
+            parser.print_help()
+
+    else:
+        for processor in processors:
+            if processor.description:
+                print " - %s: %s" % (processor.name, processor.description)
+            else:
+                print " - %s" % processor.name
 
 
 def run(args):
index ea372e76f1ec290c5ed2a4fe2c7331a6259b88fd..f4ba4e5ae3d334496929d211083000c9dc6f97c1 100644 (file)
@@ -313,7 +313,8 @@ class CommonImageProcessor(MediaProcessor):
     def resize_step(self):
         pass
 
-    def _add_width_height_args(self, parser):
+    @classmethod
+    def _add_width_height_args(cls, parser):
         parser.add_argument(
             "--width", default=None,
             help=(
@@ -332,7 +333,7 @@ class InitialProcessor(CommonImageProcessor):
     description = "Initial processing"
 
     @classmethod
-    def media_is_eligibile(self, media_entry):
+    def media_is_eligibile(cls, media_entry):
         """
         Determine if this media type is eligible for processing
         """
@@ -344,16 +345,17 @@ class InitialProcessor(CommonImageProcessor):
     ###############################
 
     @classmethod
-    def generate_parser(self):
+    def generate_parser(cls):
         parser = argparse.ArgumentParser(
-            description=self.description)
+            description=cls.description,
+            prog=cls.name)
 
-        self._add_width_height_args(parser)
+        cls._add_width_height_args(parser)
 
         return parser
 
     @classmethod
-    def args_to_request(self, args):
+    def args_to_request(cls, args):
         raise NotImplementedError
 
 
index 95622b9d7359ee3a611c0198bb8b873b979838a2..9e77d2b2e9a67750a7cd159a853ce4c95776512d 100644 (file)
@@ -126,7 +126,7 @@ class MediaProcessor(object):
         raise NotImplementedError
 
     @classmethod
-    def media_is_eligibile(self, media_entry):
+    def media_is_eligibile(cls, media_entry):
         raise NotImplementedError
 
     ###############################
@@ -134,11 +134,11 @@ class MediaProcessor(object):
     ###############################
 
     @classmethod
-    def generate_parser(self):
+    def generate_parser(cls):
         raise NotImplementedError
 
     @classmethod
-    def parser_to_request(self, parser):
+    def parser_to_request(cls, parser):
         raise NotImplementedError
 
     ##########################################