mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
feat: add command to load and execute commands from file
This commit is contained in:
parent
01439875af
commit
fc6c01a9a5
1 changed files with 24 additions and 1 deletions
|
@ -771,7 +771,6 @@ class Commands:
|
|||
all_files = [self.quote_fname(fn) for fn in all_files]
|
||||
return all_files
|
||||
|
||||
# ai add cmd_load which takes a filename. read `/commands` from each line an execute them!
|
||||
def cmd_drop(self, args=""):
|
||||
"Remove files from the chat session to free up context space"
|
||||
|
||||
|
@ -1247,6 +1246,30 @@ class Commands:
|
|||
output = f"{announcements}\n{settings}"
|
||||
self.io.tool_output(output)
|
||||
|
||||
def cmd_load(self, args):
|
||||
"Load and execute commands from a file"
|
||||
if not args.strip():
|
||||
self.io.tool_error("Please provide a filename containing commands to load.")
|
||||
return
|
||||
|
||||
try:
|
||||
with open(args.strip(), 'r') as f:
|
||||
commands = f.readlines()
|
||||
except FileNotFoundError:
|
||||
self.io.tool_error(f"File not found: {args}")
|
||||
return
|
||||
except Exception as e:
|
||||
self.io.tool_error(f"Error reading file: {e}")
|
||||
return
|
||||
|
||||
for cmd in commands:
|
||||
cmd = cmd.strip()
|
||||
if not cmd or cmd.startswith('#'):
|
||||
continue
|
||||
|
||||
self.io.tool_output(f"\nExecuting command: {cmd}")
|
||||
self.run(cmd)
|
||||
|
||||
def cmd_copy(self, args):
|
||||
"Copy the last assistant message to the clipboard"
|
||||
all_messages = self.coder.done_messages + self.coder.cur_messages
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue