mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 02:34:59 +00:00
aider: Detect if stdin is coming from a file and use normal input() if so
# Context: USER: have get_input detect if stdin is coming from a file not a terminal, if so just use normal python input() to read a line ASSISTANT: To detect if stdin is coming from a file and not a terminal, you can use `sys.stdin.isatty()`. If it returns `False`, it means the input is coming from a file. In that case, you can use the normal `input()` function to read a line. Here's the change you need to make in the `get_input` function: ```python aider/getinput.py <<<<<<< ORIGINAL def get_input(history_file, fnames): ======= import sys def get_input(history_file, fnames): if not sys.stdin.isatty(): return input() >>>>>>> UPDATED ``` This change imports the `sys` module and checks if the input is coming from a file. If it is, the function returns the input using the normal `input()` function.
This commit is contained in:
parent
b1fa3b91f9
commit
c3eb968ec4
1 changed files with 4 additions and 0 deletions
|
@ -25,7 +25,11 @@ class FileContentCompleter(Completer):
|
|||
yield Completion(word, start_position=-len(last_word))
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
def get_input(history_file, fnames):
|
||||
if not sys.stdin.isatty():
|
||||
return input()
|
||||
inp = ""
|
||||
multiline_input = False
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue