aider: Implemented cmd_help to print out a list of all the commands along with their docstring description.

# Context:
USER: implement cmd_help. have it print out a list of all the commands along with their docstring description
ASSISTANT: To implement the `cmd_help` method, we will iterate through the available commands and print their names along with their docstring descriptions.

Here's the updated code for `aider/commands.py`:

```python
aider/commands.py
<<<<<<< ORIGINAL
    def cmd_help(self, args):
        "Show help about all commands"
        pass
=======
    def cmd_help(self, args):
        "Show help about all commands"
        commands = self.get_commands()
        for cmd in commands:
            cmd_method_name = f"cmd_{cmd[1:]}"
            cmd_method = getattr(self, cmd_method_name, None)
            if cmd_method:
                description = cmd_method.__doc__
                self.console.print(f"{cmd}: {description}")
            else:
                self.console.print(f"{cmd}: No description available.")
>>>>>>> UPDATED
```

This will print the command names along with their docstring descriptions when the `cmd_help` method is called.
This commit is contained in:
Paul Gauthier 2023-05-10 11:22:55 -07:00
parent c169bdf4ba
commit 7170324214

View file

@ -4,8 +4,15 @@ class Commands:
def cmd_help(self, args):
"Show help about all commands"
pass
commands = self.get_commands()
for cmd in commands:
cmd_method_name = f"cmd_{cmd[1:]}"
cmd_method = getattr(self, cmd_method_name, None)
if cmd_method:
description = cmd_method.__doc__
self.console.print(f"{cmd}: {description}")
else:
self.console.print(f"{cmd}: No description available.")
def cmd_ls(self, args):
"List files and show their chat status"
print("ls")