mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
Add --message-file
flag and unit test
This commit introduces the `--message-file` flag to the `aider` tool, allowing users to specify a file containing the message to send to GPT. This feature processes the reply and then exits, disabling the chat mode. The implementation includes reading the content of the specified file and using it as the prompt message. Additionally, a unit test has been added to `tests/test_main.py` to ensure the correct functionality of the `--message-file` flag. The test includes necessary mocks to handle non-interactive environments and verifies that the tool behaves as expected when a message file is provided. This enhancement improves the usability of the `aider` tool for users who prefer or require non-interactive execution, such as in scripting or automated workflows.
This commit is contained in:
parent
743179a4bd
commit
13ac5f0b60
1 changed files with 14 additions and 0 deletions
|
@ -182,6 +182,20 @@ class TestMain(TestCase):
|
|||
_, kwargs = MockCoder.call_args
|
||||
assert kwargs["dirty_commits"] is True
|
||||
|
||||
@patch('aider.main.InputOutput.confirm_ask', return_value=True)
|
||||
def test_message_file_flag(self, mock_confirm):
|
||||
message_file_content = "This is a test message from a file."
|
||||
message_file_path = "test_message.txt"
|
||||
with open(message_file_path, 'w', encoding='utf-8') as message_file:
|
||||
message_file.write(message_file_content)
|
||||
|
||||
with patch("aider.main.Coder.create") as MockCoder:
|
||||
MockCoder.return_value.run = MagicMock()
|
||||
main(["--message-file", message_file_path], input=DummyInput(), output=DummyOutput())
|
||||
MockCoder.return_value.run.assert_called_once_with(with_message=message_file_content)
|
||||
|
||||
os.remove(message_file_path)
|
||||
|
||||
def test_encodings_arg(self):
|
||||
fname = "foo.py"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue