def get_command(self, ctx, name):
<EOL>if not hasattr(self.resource, name):<EOL><INDENT>return None<EOL><DEDENT>method = getattr(self.resource, name)<EOL>attrs = getattr(method, '<STR_LIT>', {})<EOL>help_text = inspect.getdoc(method)<EOL>attrs['<STR_LIT>'] = self._auto_help_text(help_text or '<STR_LIT>')<EOL>ignore_defaults = attrs.pop('<STR_LIT>', False)<EOL>new_method = self._echo_method(method)<EOL>click_params = getattr(method, '<STR_LIT>', [])<EOL>new_method.__click_params__ = copy(click_params)<EOL>new_method = with_global_options(new_method)<EOL>fao = attrs.pop('<STR_LIT>', True)<EOL>if fao:<EOL><INDENT>for field in reversed(self.resource.fields):<EOL><INDENT>if not field.is_option:<EOL><INDENT>continue<EOL><DEDENT>if not isinstance(fao, bool) and field.name not in fao:<EOL><INDENT>continue<EOL><DEDENT>args = [field.option]<EOL>if field.key:<EOL><INDENT>args.insert(<NUM_LIT:0>, field.key)<EOL><DEDENT>short_fields = {<EOL>'<STR_LIT:name>': '<STR_LIT:n>',<EOL>'<STR_LIT:description>': '<STR_LIT:d>',<EOL>'<STR_LIT>': '<STR_LIT:i>',<EOL>'<STR_LIT>': '<STR_LIT:e>'<EOL>}<EOL>if field.name in short_fields:<EOL><INDENT>args.append('<STR_LIT:->'+short_fields[field.name])<EOL><DEDENT>option_help = field.help<EOL>if isinstance(field.type, StructuredInput):<EOL><INDENT>option_help += '<STR_LIT>'<EOL><DEDENT>if field.required:<EOL><INDENT>option_help = '<STR_LIT>' + option_help<EOL><DEDENT>elif field.read_only:<EOL><INDENT>option_help = '<STR_LIT>' + option_help<EOL><DEDENT>option_help = '<STR_LIT>' + option_help<EOL>click.option(<EOL>*args,<EOL>default=field.default if not ignore_defaults else None,<EOL>help=option_help,<EOL>type=field.type,<EOL>show_default=field.show_default,<EOL>multiple=field.multiple,<EOL>is_eager=False<EOL>)(new_method)<EOL><DEDENT><DEDENT>cmd = click.command(name=name, cls=ActionSubcommand, **attrs)(new_method)<EOL>code = six.get_function_code(method)<EOL>if '<STR_LIT>' in code.co_varnames:<EOL><INDENT>click.argument('<STR_LIT>', nargs=<NUM_LIT:1>, required=False, type=str, metavar='<STR_LIT>')(cmd)<EOL><DEDENT>return cmd<EOL>
Retrieve the appropriate method from the Resource,
        decorate it as a click command, and return that method.