diff --git a/aider/main.py b/aider/main.py index fe4e8517c..fe0821d08 100644 --- a/aider/main.py +++ b/aider/main.py @@ -382,7 +382,7 @@ def main(argv=None, input=None, output=None, force_git_root=None): ) other_group.add_argument( "--message-file", - "-mf", + "-f", metavar="MESSAGE_FILE", help="Specify a file containing the message to send GPT, process reply, then exit (disables chat mode)", ) @@ -571,8 +571,7 @@ def main(argv=None, input=None, output=None, force_git_root=None): coder.run(with_message=args.message) elif args.message_file: try: - with open(args.message_file, 'r', encoding='utf-8') as file: - message_from_file = file.read() + message_from_file = io.read_text(args.message_file) io.tool_output() coder.run(with_message=message_from_file) except FileNotFoundError: diff --git a/tests/test_main.py b/tests/test_main.py index fc363ce5f..b61de9d90 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -182,16 +182,15 @@ 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): + def test_message_file_flag(self): message_file_content = "This is a test message from a file." - message_file_path = "test_message.txt" + message_file_path = tempfile.mktemp() 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()) + main(["--yes", "--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)