mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
Added a new method do_run and improved error messages.
This commit is contained in:
parent
8b2fdd4b92
commit
126b5e1f3b
1 changed files with 8 additions and 2 deletions
|
@ -13,18 +13,24 @@ class Commands:
|
|||
|
||||
return commands
|
||||
|
||||
def do_run(self, cmd_name, args):
|
||||
pass
|
||||
|
||||
def run(self, inp, console):
|
||||
words = inp.strip().split()
|
||||
if not words:
|
||||
return
|
||||
|
||||
first_word = words[0]
|
||||
rest_inp = inp[len(words[0]):]
|
||||
|
||||
all_commands = self.get_commands()
|
||||
matching_commands = [cmd for cmd in all_commands if cmd.startswith(first_word)]
|
||||
|
||||
if len(matching_commands) == 1:
|
||||
console.print('[green]run', matching_commands[0])
|
||||
self.do_run(matching_commands[0][1:], rest_inp)
|
||||
elif len(matching_commands) > 1:
|
||||
console.print('[yellow]Partial matches:', ', '.join(matching_commands))
|
||||
console.print('[red]Ambiguous command:', ', '.join(matching_commands))
|
||||
else:
|
||||
console.print('[red]Error: Command not found')
|
||||
console.print(f'[red]Error: {first_word} is not a valid command.')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue