You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/03/25 21:35:52 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #7873: Add help message in celery command

mik-laj commented on a change in pull request #7873: Add help message in celery command
URL: https://github.com/apache/airflow/pull/7873#discussion_r398184886
 
 

 ##########
 File path: airflow/cli/cli_parser.py
 ##########
 @@ -55,6 +56,28 @@ def command(*args, **kwargs):
     return command
 
 
+class DefaultHelpParser(argparse.ArgumentParser):
+    """CustomParser to display help message"""
+    custom_msg = {'celery': 'celery command cab be used in CeleryExcutor'}
+
+    def _check_value(self, action, value):
+        """Override _check_value and check conditionally added command"""
+        if action.choices is not None and value not in action.choices:
+            args = {'value': value,
 
 Review comment:
   ```suggestion
       if value in self.custom_msg:
           msg = self.custom_msg[value]
       else:
           args = {
               'value': value,
               'choices': ', '.join(map(repr, action.choices))
           }
           msg = gettext('invalid choice: %(value)r (choose from %(choices)s)') % args
   ```
   It is not necessary to generate a generic message in all cases.  If we have a special message, we display it. When we don't have it, we create it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services